缓存

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将返回缓存数据,同时执行一次缓存刷新


最近更新 搜索 提交