redis五大类型用法
List: redisTemplate.opsForList().leftPush(key, value);//从左向右存压栈redisTemplate.opsForList().leftPop(key);//从左出栈
redisTemplate.opsForList().size(key);//队/栈长
redisTemplate.opsForList().range(key, start, end);//范围检索,返回List
redisTemplate.opsForList().remove(key, i, value);//移除key中值为value的i个,返回删除的个数;如果没有这个元素则返回0
redisTemplate.opsForList().index(key, index);//检索
redisTemplate.opsForList().set(key, index, value);//赋值
redisTemplate.opsForList().trim(key, start, end);//裁剪,void,删除除了以外的所有元素
redisTemplate.opsForList().rightPopAndLeftPush(String sourceKey, String destinationKey);//将源key的队列的右边的一个值删除,然后塞入目标key的队列的左边,返回这个值
注意:要缓存的对象必须实现Serializable接口,因为 Spring 会将对象先序列化再存入 Redis,否则报异常nested exception is java.lang.IllegalArgumentException: DefaultSerializer requires a Serializable……//;;/
页:
[1]