使用相同的配置,仅使用 defaultCache,我得到不一致的数据(情况 A)。但是,如果我添加额外的缓存条目,就不会出现这些不一致的错误(情况 B)。
你知道为什么吗?
我不想设置 aumaticamente defaultCache 的 130 个缓存
提前致谢
P。 S.我一直猜想,没有指定什么,就会将EHCache作为模板使用defaultCache设置。
案例A:
<defaultCache
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="0"
overflowToDisk="false"
>
<cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
/>
<bootstrapCacheLoaderFactory class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory" />
</defaultCache>
`
案例B:
<defaultCache
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="0"
overflowToDisk="false"
>
<cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
/>
<bootstrapCacheLoaderFactory class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory" />
</defaultCache>
<cache
name="com.liferay.portal.model.impl.LayoutImpl"
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="0"
overflowToDisk="false"
>
<cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
/>
<bootstrapCacheLoaderFactory class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory" />
</cache>
最佳答案
由于您没有说明如何使用缓存,因此很难猜测您真正在做什么以及您的意思是哪些不一致错误。
也许您没有使用缓存实体来缓存查询结果,这使得从缓存中读取实体并从数据库中查询?有很多可能的情况。
关于java - 分布式环境下的defaultCache和cache问题(数据不一致),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5142330/