Spring Data Redis
3.1.1Spring Data Redis是 Spring Data 系列中占比较大的一部分,可轻松配置并从 Spring 应用程序访问 Redis。它提供了与 store 交互的低层和高层抽象,使用户摆脱了基础设施方面的顾虑。
特性
-
跨多个 Redis 驱动程序低级抽象的连接库(https://github.com/lettuce-io/lettuce-core[Lettuce] 和 Jedis)。
-
将 Redis 驱动程序异常转换为 Spring 的数据访问异常层次结构的 异常。
-
RedisTemplate 提供了用于执行各种 Redis 操作,异常转换和序列化支持的高级抽象。
-
Pubsub 支持(例如,消息驱动的 POJO 的 MessageListenerContainer)。
-
Redis Sentinel 和 Redis Cluster 支持。
-
使用 Lettuce 驱动程序的响应式API。
-
JDK,String,JSON 和 Spring Object/XML 映射序列化器。
-
Redis 之上的 JDK Collection 实现。
-
排序和管道
-
支持 SORT,SORT/GET 模式和返回批量值。
-
Spring 3.1 缓存抽象的 Redis 实现。
-
Repository 接口的自动实现,包括使用
@EnableRedisRepositories支持自定义查询方法。 -
对存储库的 CDI 支持。
Configure RedisTemplate….
<bean id="jedisConnFactory"
class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
p:use-pool="true"/>
<!-- redis template definition -->
<bean id="redisTemplate"
class="org.springframework.data.redis.core.RedisTemplate"
p:connection-factory-ref="jedisConnFactory"/>
Inject and use RedisTemplate or any of its opsForX() instances….
public class Example {
// inject the actual template
@Autowired
private RedisTemplate<String, String> template;
// inject the template as ListOperations
// can also inject as Value, Set, ZSet, and HashOperations
@Resource(name="redisTemplate")
private ListOperations<String, String> listOps;
public void addLink(String userId, URL url) {
listOps.leftPush(userId, url.toExternalForm());
// or use template directly
redisTemplate.boundListOps(userId).leftPush(url.toExternalForm());
}
}
文档
每个 Spring 项目 都有自己的项目;它详细地解释了如何使用 项目特性,以及利用它们可以实现什么。
| 3.1.1 CURRENT GA | 官方参考文档. | API Doc. | |
| 3.0.7 GA | 官方参考文档. | API Doc. | |
| 3.0.0 GA | 官方参考文档. | 中文参考文档. | API Doc. |
| 2.7.13 GA | 官方参考文档. | API Doc. | |
| 2.6.6 GA | 官方参考文档. | 中文参考文档. | API Doc. |
| 2.4.8 GA | 官方参考文档. | 中文参考文档. | API Doc. |
| 2.3.9.RELEASE GA | 官方参考文档. | 中文参考文档. | API Doc. |
| 2.2.12.RELEASE GA | 官方参考文档. | 中文参考文档. | API Doc. |
| 分支 | 版本发布日期 | 社区支持结束日期 | 商业支持结束日期 * |
|---|---|---|---|
|
3.1.x
|
2023-05-12 | 2024-05-12 | 2025-09-12 |
|
3.0.x
|
2022-11-18 | 2023-11-18 | 2025-03-18 |
|
2.7.x
|
2022-05-01 | 2023-11-18 | 2025-02-18 |
|
2.6.x
|
2021-11-12 | 2022-11-12 | 2024-03-12 |
|
2.5.x
|
2021-04-14 | 2022-04-14 | 2023-08-14 |
|
2.4.x
|
2020-10-28 | 2021-10-28 | 2023-02-28 |
|
2.3.x
|
2020-05-12 | 2021-05-12 | 2022-09-12 |
|
2.2.x
|
2019-09-30 | 2020-09-30 | 2022-01-30 |
|
2.1.x
|
2018-09-21 | 2019-09-21 | 2021-01-21 |
社区支持
在 Spring 社区的支持下免费进行安全更新和错误修复。 请参阅 VMware Tanzu OSS 支持策略.
商业支持
在 OSS 期限内由 Spring 专家提供专业业务支持,并在 OSS 生命周期结束后提供扩展支持。
应客户要求公开发布关键错误修复和安全问题。
未来版本
未发布 GA 版本,时间表可能会发生变化。.