anyline-web默認(rèn)集成了ehcache作為一級(jí)緩存,在anyline-config.xml中通過(guò)IS_USE_CACHE開(kāi)啟。
同時(shí)需要添加ehcache的配置文件ehcache.xml,ehcache.xsd,并定義緩存空間
<cache name="static_1800"
maxElementsInMemory="10000"
eternal="false"
overflowToDisk="false"
timeToIdleSeconds="1800"
timeToLiveSeconds="1800"
memoryStoreEvictionPolicy="LFU" />
以上配置1800秒緩存時(shí)間
在AnylineService查詢(xún)時(shí)可以調(diào)用緩存
AnylineService.cache("static_1800","表","查詢(xún)條件");
AnylineService.cacheRow("static_1800","表","查詢(xún)條件");
cache方法不會(huì)等到1800秒后再刷新緩存,當(dāng)緩存時(shí)間達(dá)到90%的時(shí),此時(shí)再查詢(xún)cache將返回緩存數(shù)據(jù),同時(shí)執(zhí)行一次緩存刷新
AnylineService默認(rèn)集成了ehcache緩存、需要先在ehcache.xml中配置緩存
service.query("緩存key","表名","查詢(xún)條件")
與查詢(xún)數(shù)據(jù)庫(kù)參數(shù)一致
更多建議: