<返回更多

捋一捋RedisTemplate

2021-06-22    程序有个家
加入收藏

1.redisTemplate类所在的包路径:

org.springframework.data.redis.core.RedisTemplate

2.redisTemplate序列化,需要序列化四个地方,keySerializer, valueSerializer,hashKeySerializer,hashValueSerializer:

@Nullable
private RedisSerializer keySerializer = null;
@Nullable
private RedisSerializer valueSerializer = null;
@Nullable
private RedisSerializer hashKeySerializer = null;
@Nullable
private RedisSerializer hashValueSerializer = null;

3.RedisTemplate可以通过什么方法返回什么对象对数据进行操作?

3.1.常用的获取操作数据的对象方法,opsForValue(),opsForHash(),opsForList(),opsForSet(),opsForZSet(),opsForStream(),opsForGeo(),如下:

捋一捋RedisTemplate

 

3.2.返回的操作对象类型:ValueOperations,ListOperations,SetOperations,StreamOperations,ZSetOperations,GeoOperations,HyperLogLogOperations,ClusterOperations。如下:

private final ValueOperations<K, V> valueOps = new DefaultValueOperations(this);
private final ListOperations<K, V> listOps = new DefaultListOperations(this);
private final SetOperations<K, V> setOps = new DefaultSetOperations(this);
private final StreamOperations<K, ?, ?> streamOps = new DefaultStreamOperations(this, ObjectHashMApper.getSharedInstance());
private final ZSetOperations<K, V> zSetOps = new DefaultZSetOperations(this);
private final GeoOperations<K, V> geoOps = new DefaultGeoOperations(this);
private final HyperLogLogOperations<K, V> hllOps = new DefaultHyperLogLogOperations(this);
private final ClusterOperations<K, V> clusterOps = new DefaultClusterOperations(this);

4.ValueOperations的常用方法

捋一捋RedisTemplate

 

5.ListOperations的常用方法

捋一捋RedisTemplate

 

6.SetOperations的常用方法

捋一捋RedisTemplate

 

7.StreamOperations的常用方法

捋一捋RedisTemplate

 


捋一捋RedisTemplate

 

8.ZSetOperations的常用方法

捋一捋RedisTemplate

 


捋一捋RedisTemplate

 

9.GeoOperations的常用方法

捋一捋RedisTemplate

 

10.HyperLogLogOperations的常用方法

捋一捋RedisTemplate

 

11.ClusterOperations的常用方法

捋一捋RedisTemplate

 

声明:本站部分内容来自互联网,如有版权侵犯或其他问题请与我们联系,我们将立即删除或处理。
▍相关推荐
更多资讯 >>>