时间:2023-01-15 11:42:56 | 栏目:JAVA代码 | 点击:次
resty的缓存设计极其简单,目前分为两部分,model数据缓存和session缓存,第3条使用权限控制时,session被存入缓存,便于实现分布式,支持 ehcache和 redis
app.cacheEnabled=true #如果不配置cacheManager对象,默认使用ehcacheManager #app.cacheManager=cn.dreampie.cache.redis.RedisManager
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
//model
@Table(name = "sec_user",generatedKey="id", primaryKey = "sid", cached = true)
//record
Record recordDAO = new Record("sec_user", true);