我们在 Grails 环境中配置了 ehcache,我正在尝试确定如何使用远程 terracotta 缓存配置本地缓存。
场景是我们有一些计算成本最低的数据,并且从本地内存缓存中受益,但在使用远程 terracotta 缓存时 yield 最小化。
配置目前非常简单:
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ehcache.xsd" >
<diskStore path="java.io.tmpdir"/>
<cacheManagerEventListenerFactory class="" properties=""/>
<defaultCache
maxElementsInMemory="20000"
eternal="false"
timeToLiveSeconds="12000"
overflowToDisk="false"
diskPersistent="false">
<terracotta />
</defaultCache>
<terracottaConfig url="${com.ngs.app.tc.host}:${com.ngs.app.tc.port}" />
<cache name="org.hibernate.cache.UpdateTimestampsCache"
maxElementsInMemory="10000"
timeToIdleSeconds="300"/>
<cache name="org.hibernate.cache.StandardQueryCache"
maxElementsInMemory="10000"
timeToIdleSeconds="300"/>
</ehcache>
问题是:
感谢您的任何建议...
最佳答案
几点:
maxElementsInMemory
的设置将应用于缓存的堆上层,在 Terracotta 集群的每个 JVM 部分本地。注:maxElementsInMemory
已弃用,应替换为 maxEntriesLocalHeap
在最近的 Ehcache 版本中。 鉴于此,以下是基本操作及其与缓存的聚集位的关系:
对于最后两个操作,默认配置将本地操作与集群操作分离。如果您无法处理读取过时的值,您可以使用 consistency setting .
这意味着您的问题的答案是:
terracotta
缓存配置中的元素。如果您需要集群位但希望大多数缓存命中是本地命中,则需要调整集群缓存配置。 关于结合远程 Terracotta 配置的 Grails 本地 ehcache,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27538768/