codecamp

anyline 缓存

anyline-web默认集成了ehcache作为一级缓存,在anyline-config.xml中通过IS_USE_CACHE开启。

同时需要添加ehcache的配置文件ehcache.xml,ehcache.xsd,并定义缓存空间

<cache name="static_1800"
        maxElementsInMemory="10000"
        eternal="false"
        overflowToDisk="false"
        timeToIdleSeconds="1800"
        timeToLiveSeconds="1800"
        memoryStoreEvictionPolicy="LFU" />

以上配置1800秒缓存时间

在AnylineService查询时可以调用缓存

AnylineService.cache("static_1800","表","查询条件");

AnylineService.cacheRow("static_1800","表","查询条件");

cache方法不会等到1800秒后再刷新缓存,当缓存时间达到90%的时,此时再查询cache将返回缓存数据,同时执行一次缓存刷新

默认缓存

AnylineService默认集成了ehcache缓存、需要先在ehcache.xml中配置缓存
service.query("缓存key","表名","查询条件")
与查询数据库参数一致


anyline 数据库操作
anyline 分页
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }