Spring SimpleCacheManager 更新策略?
Spring SimpleCacheManager update strategy?
我正在将缓存添加到我的应用程序中一个小但经常使用的数据库调用。它命中的 table 将很少更新,因此它是一个很好的缓存候选者。我已经用 org.springframework.cache.support.SimpleCacheManager 实现了它,我想知道更多关于它的更新策略,但我似乎找不到任何关于它的信息。
最主要的是,我想知道它是否会定期清除缓存,如果会,它是按照什么样的时间表执行的?我几乎可以肯定默认缓存会起作用,但我想确定一下。
The properties you have to know are "timeToIdleSeconds" and
"timeToLiveSeconds" (in ehcache caching framework) which will decide how long the cache objects are
valid for. Once the cache data becomes invalid, the data will be fetched again from
database again and kept into cache.
请找到下面 spring 的示例 ehcache 配置。
<cache name="myProjectCache"
maxEntriesLocalHeap="10000"
memoryStoreEvictionPolicy="LFU"
timeToIdleSeconds="300" timeToLiveSeconds="600">
</cache>
此外,请参考以下 spring 缓存文档:
http://docs.spring.io/spring/docs/current/spring-framework-reference/html/cache.html
您可以在下面找到一个简单的 spring-ehcache 示例:
http://www.mkyong.com/spring/spring-caching-and-ehcache-example/
我正在将缓存添加到我的应用程序中一个小但经常使用的数据库调用。它命中的 table 将很少更新,因此它是一个很好的缓存候选者。我已经用 org.springframework.cache.support.SimpleCacheManager 实现了它,我想知道更多关于它的更新策略,但我似乎找不到任何关于它的信息。
最主要的是,我想知道它是否会定期清除缓存,如果会,它是按照什么样的时间表执行的?我几乎可以肯定默认缓存会起作用,但我想确定一下。
The properties you have to know are "timeToIdleSeconds" and "timeToLiveSeconds" (in ehcache caching framework) which will decide how long the cache objects are valid for. Once the cache data becomes invalid, the data will be fetched again from database again and kept into cache.
请找到下面 spring 的示例 ehcache 配置。
<cache name="myProjectCache"
maxEntriesLocalHeap="10000"
memoryStoreEvictionPolicy="LFU"
timeToIdleSeconds="300" timeToLiveSeconds="600">
</cache>
此外,请参考以下 spring 缓存文档:
http://docs.spring.io/spring/docs/current/spring-framework-reference/html/cache.html
您可以在下面找到一个简单的 spring-ehcache 示例:
http://www.mkyong.com/spring/spring-caching-and-ehcache-example/