RedisConnection&RedisConnectionFactory
首推Redis客户端为Lettuce(spring-boot-starter-data-redis默认已集成
),Jedis也支持(需要自行添加)。
Lettuce:
1 |
|
Jedis:
1 |
|
RedisConnection代表Redis客户端与Redis服务端的连接,一般通过RedisConnectionFactory(LettuceConnectionFactory或JedisConnectionFactory)创建,创建RedisConnectionFactory需要客户端配置(包括连接池(基于commons-pool2
))和单机、哨兵或集群配置。
客户端配置
Lettuce
Jedis
连接池
Lettuce之前使用的LettucePool不再支持,已被LettucePoolingClientConfiguration替代
Jedis使用JedisPoolConfig
都是基于commons-pool2实现
单机
RedisStandaloneConfiguration
哨兵
RedisSentinelConfiguration
集群
RedisClusterConfiguration
样例
Lettuce
1 |
|
Jedis
1 |
|
RedisTemplate
操作Redis的入口,提供了丰富的操作集,相对于RedisConnection
提供较低级别的操作,RedisTemplate
提供了较高级别的抽象。
同时根据Redis的键类型或值类型,提供了多种抽象的操作视图,包括丰富且泛型化的操作集。
Interface | Description |
---|---|
Key Type Operations | |
GeoOperations | Redis geospatial operations like GEOADD , GEORADIUS ,…) |
HashOperations | Redis hash operations |
HyperLogLogOperations | Redis HyperLogLog operations like (PFADD , PFCOUNT ,…) |
ListOperations | Redis list operations |
SetOperations | Redis set operations |
ValueOperations | Redis string (or value) operations |
ZSetOperations | Redis zset (or sorted set) operations |
Key Bound Operations | |
BoundGeoOperations | Redis key bound geospatial operations. |
BoundHashOperations | Redis hash key bound operations |
BoundKeyOperations | Redis key bound operations |
BoundListOperations | Redis list key bound operations |
BoundSetOperations | Redis set key bound operations |
BoundValueOperations | Redis string (or value) key bound operations |
BoundZSetOperations | Redis zset (or sorted set) key bound operations |
样例
1 |
|
1 |
|
Serializers
Redis Message/PubSub
Redis Transactions
Reactive Redis Support
只有Lettuce支持Reactive,Jedis不支持
ReactiveRedisConnectionFactory
ReactiveRedisTemplate
Interface | Description |
---|---|
Key Type Operations | |
ReactiveGeoOperations | Redis geospatial operations like GEOADD , GEORADIUS ,…) |
ReactiveHashOperations | Redis hash operations |
ReactiveHyperLogLogOperations | Redis HyperLogLog operations like (PFADD , PFCOUNT ,…) |
ReactiveListOperations | Redis list operations |
ReactiveSetOperations | Redis set operations |
ReactiveValueOperations | Redis string (or value) operations |
ReactiveZSetOperations | Redis zset (or sorted set) operations |
1 |
|
1 |
|
Redis Repositories
Reactive Repositories
QA
spring boot project
1 |
|