resty的緩存技術(shù)設(shè)計及使用
resty的緩存設(shè)計極其簡單,目前分為兩部分,model數(shù)據(jù)緩存和session緩存,第3條使用權(quán)限控制時,session被存入緩存,便于實現(xiàn)分布式,支持 ehcache和 redis
1. 在application.properties里啟用緩存,并配置緩存對象
app.cacheEnabled=true #如果不配置cacheManager對象,默認(rèn)使用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 緩存永久的 程序自動清理過期的數(shù)據(jù)-->
<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的構(gòu)造參數(shù)開啟緩存
//model
@Table(name = "sec_user",generatedKey="id", primaryKey = "sid", cached = true)
//record
Record recordDAO = new Record("sec_user", true);以上就是resty的緩存技術(shù)設(shè)計及使用的詳細(xì)內(nèi)容,更多關(guān)于resty緩存設(shè)計使用的資料請關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
關(guān)于mybatis if else if 條件判斷SQL片段表達(dá)式取值和拼接問題
這篇文章主要介紹了mybatis if else if 條件判斷SQL片段表達(dá)式取值和拼接,文章通過自己真實使用的例子給大家詳細(xì)介紹,需要的朋友可以參考下2021-09-09
MyBatis學(xué)習(xí)教程(七)-Mybatis緩存介紹
MyBatis緩存分為一級緩存和二級緩存一級緩存,本文給大家介紹mybatis緩存知識,非常不錯具有參考借鑒價值,感興趣的朋友一起學(xué)習(xí)吧2016-05-05
關(guān)于Spring中一級緩存、二級緩存和三級緩存的那些事
Spring解決循環(huán)依賴的核心思想在于提前曝,下面這篇文章主要給大家介紹了關(guān)于Spring中一級緩存、二級緩存和三級緩存的那些事,文中通過實例代碼介紹的非常詳細(xì),需要的朋友可以參考下2022-02-02

