从右侧插入队列(插入string)
public int lSet(String key, String value) {
try {
redisTemplate.opsForList().rightPush(key, value);
return 1;
} catch (Exception e) {
e.printStackTrace();
return 0;
}
}
从右侧插入队列(插入list)
public int llSetAll(String key, List<V> values) {
try {
if(CollectionUtils.isEmpty(values)){
return 0;
}
redisTemplate.opsForList().rightPushAll(key,values );
}
return values.size();
} catch (Exception e) {
e.printStackTrace();
return 0;
}
}
从左侧获取队列
public Object leftPop(String key) {
try {
return redisTemplate.opsForList().leftPop(key);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}