1 Star 0 Fork 0

zhaojin / spring-data-redis

Create your Gitee Account
Explore and code with more than 6 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Without author's permission, this code is only for learning and cannot be used for other purposes.
Clone or download
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README.md

Spring Data Redis Spring Data Redis

Spring Data Redis Plus

The primary goal of the Spring Data project is to make it easier to build Spring-powered applications that use new data access technologies such as non-relational databases, map-reduce frameworks, and cloud based data services. This modules provides integration with the Redis store.

redis_plus缓存 方案(方案实例:User(用户表),UserBank(用户银行卡)):

  • 自动缓存更新方案:
  • 1、del:无需特别处理,即可确保查询最新数据(删除一条,当缓存数据List中含本条数据会导致组织失败,重新执行查询)
  • 2、update:分为两种情况,
  • a、更新了无关字段, 比如更新了用户表中昵称,则 @CachePut(key = "#p0.id") 即可
  • b、更新了有关字段,比如更新了 用户银行卡中得status为0(无效了),则:@CachePut(key = "#p0.id") 和 @Caching( evict = {@CacheEvict(key = "'&userId='+#userId+'*'")}) *附:所谓无关有关,判断条件:这个字段有没有在查询条件中,比如 用户表中昵称判断为无关业务没有基于昵称得查询否则不成功,
  • 所谓有关 ,这个字段在查询条件中,比如存在我得银行卡业务查询并缓存了 @Cacheable( key = "'&userId='+#p0+'&page='+#p1.pageNumber+'&size='+#p1.pageSize"),现在更新了status=0,则影响了这个缓存结果所以判断为这个查询有关,需要清除这个缓存
  • 3、add:也是影响查询结果集合,比如我添加了一张银行卡则: @Caching( evict = {@CacheEvict(key = "'&userId='+#p0.userId+'&*'")})
  • 4、此方案生效有几个条件
  • a、实体 存在 @Id:用于标记属性的主键(复合主键未测试)
  • b、key得规范:&a=1&b=2&b=3 类似这样,比如查询用户得银行卡:key = "'&userId='+#p0+'&page='+#p1.pageNumber+'&size='+#p1.pageSize"
  • c、evict得key模糊匹配方案(存在才为模糊匹配方案,否则为标准key方案):&a=1&b=2&b=3&,比如用户银行添加了银行卡则evict key:key = "'&userId='+#userId+'&*'"

Docs

使用案例 传送门

Comments ( 0 )

Sign in for post a comment

About

Spring-data-redis 加强版本,主要优化修改数据的场景下,关联缓存更新。 基本版中支持清除全部以及指定key,本方案支持 模糊匹配删除 spread retract
Java
Cancel

Releases

No release

Contributors

All

Activities

load more
can not load any more
Java
1
https://gitee.com/RemoteControl/spring-data-redis.git
git@gitee.com:RemoteControl/spring-data-redis.git
RemoteControl
spring-data-redis
spring-data-redis
master

Search

102255 3a0e046c 1850385 102255 7aaa926c 1850385