阅读(588) (34)

anyline 缓存

2022-09-15 10:14:51 更新

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","表名","查询条件")
与查询数据库参数一致