resty的缓存技术设计及使用
更新时间:2022年03月07日 15:48:01 作者:Dreampie
这篇文章主要为大家介绍了resty缓存技术的设计及使用示例,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步
resty的缓存设计极其简单,目前分为两部分,model数据缓存和session缓存,第3条使用权限控制时,session被存入缓存,便于实现分布式,支持 ehcache和 redis
1. 在application.properties里启用缓存,并配置缓存对象
app.cacheEnabled=true #如果不配置cacheManager对象,默认使用ehcacheManager #app.cacheManager=cn.dreampie.cache.redis.RedisManager
2. 在resources下配置缓存文件
ehcache.xml
<ehcache name="shiro" updateCheck="false" monitoring="autodetect" dynamicConfig="true"> <diskStore path="java.io.tmpdir/resty-ehcache"/> <defaultCache maxElementsInMemory="10000" eternal="false" timeToIdleSeconds="360" timeToLiveSeconds="360" overflowToDisk="false" diskPersistent="false" diskExpiryThreadIntervalSeconds="120"/> <cache name="_credential" maxElementsInMemory="10000" eternal="false" timeToIdleSeconds="1200" overflowToDisk="false" diskPersistent="false" diskExpiryThreadIntervalSeconds="120"/> <!--session 缓存永久的 程序自动清理过期的数据--> <cache name="_session" maxElementsInMemory="10000" eternal="true" overflowToDisk="true" diskPersistent="true" diskExpiryThreadIntervalSeconds="120"/> </ehcache>
redis.properties
redis.host=127.0.0.1:6379 #如果使用ShardInfo 逗号分割 #redis.shard.host=127.0.0.1:6379,127.0.0.1:6379 redis.timeout=0 redis.pool.maxWaitMillis=-1 redis.pool.minEvictableIdleTimeMillis=1800000
3. 在Model的table配置中,Record的构造参数开启缓存
//model @Table(name = "sec_user",generatedKey="id", primaryKey = "sid", cached = true) //record Record recordDAO = new Record("sec_user", true);
以上就是resty的缓存技术设计及使用的详细内容,更多关于resty缓存设计使用的资料请关注脚本之家其它相关文章!
相关文章
SpringCloud组件之Eureka Server详细启动过程及说明
这篇文章主要介绍了SpringCloud组件之Eureka Server详细启动过程及说明,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教2024-01-01Java读取resources中资源文件路径以及jar中文件无法读取的解决
这篇文章主要介绍了Java读取resources中资源文件路径以及jar中文件无法读取的解决方案,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教2023-05-05Java导出多个excel表打包到zip文件中供客户端另存为窗口下载实现方法
最近的项目有一个导出汇总数据的要求,考虑到用户软件的差异,所以要分别导出xls以及xlsx并且打包提供下载,下面这篇文章主要给大家介绍了关于Java导出多个excel表打包到zip文件中供客户端另存为窗口下载的实现方法,需要的朋友可以参考下2023-12-12springboot 自定义权限标签(tld),在freemarker引用操作
这篇文章主要介绍了springboot 自定义权限标签(tld),在freemarker引用操作,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧2020-09-09
最新评论