spring redis cache使用思考
来源:互联网 发布:如何查看mac的ip地址 编辑:程序博客网 时间:2024/05/19 12:29
项目中使用spring redis cache做为cache客户端。
spring redis cache中RedisCache是整个spring cache的领域模型,对应一个cache块的操作类。
RedisCache中定义了put,get,clean,evict操作。
其中clean方法用于清除当前cache块中所有的元素,这里会加锁,而锁的实现是往redis服务器上存放一个key为:cache块名称加上~lock的元素。最后清除锁则是在clean方法执行完成后在finally中清除。
put与get方法运行时会查看是否存在lock锁,存在则会sleep 300毫秒。这个过程会一直继续,直到redis服务器上不存在锁时才会进行相应的get与put操作。
这里存在一个问题,如果clean方法运行时间很长,这时当前运行clean操作的机子挂了,就导致lock元素一直存在于redis服务器上。
之后就算这个机子重新启动后,也无法正常使用cache。原因是:get与put方法在运行时,锁lock始终存在于redis服务器上。
项目运行中,遇到了这种情况。
总结:
在开发过程中,如果使用到开源框架中的某个方法,一定要深入了解其实现方式,运用场景。最坏的情况是什么。
1 0
- spring redis cache使用思考
- spring+redis(redis当cache使用)
- spring cache使用redis做缓存
- Spring Cache与Redis结合使用
- 使用spring cacheManager配置Guava Cache和Redis Cache
- 使用spring cacheManager配置Guava Cache和Redis Cache
- Spring-Boot (四) cache/ehcache/redis-cache集成使用
- Spring Cache集成redis
- Spring Cache注解+Redis
- Spring Cache集成redis
- Spring cache +redis
- Spring Cache注解+Redis
- 在 spring boot 中使用spring cache + redis
- Spring Cache + Redis配置备忘
- 基spring cache 整合redis
- 注解Spring Cache+Redis缓存
- redis与spring cache集成
- Spring cache+ redis与redis 的比较
- 正则表达式 将SQL条件的左边字段和右边值分别取出来
- Solr对数据库建立索引
- pthread多线程资源回收策略
- android myclass
- Placement new、operator new、new operator
- spring redis cache使用思考
- Storm编程
- 灵活隐藏、显示自定义tabBarController
- 学习笔记:胖model和瘦model
- 认识slick
- shell与export命令
- 送给那些即将高考和已经步入大学的同学们
- 实现 复制 粘贴功能
- 周鸿袆: 教您打造十页完美商业计划书