我们拥有一个EHCache集群,使用Hibernate和Mysql。
一切都运作得几乎完美。标准查询被缓存,并且当其他集群成员上的记录被修改时,缓存的查询会立即在其他服务器上更新。
然而,我的问题是当插入新记录时,那个表上的缓存查询不知道它,直到缓存查询过期。
我可能在我的EHcache.xml配置中漏掉了某些内容,但我不知道可能是什么。
有任何想法吗?
以下是EHCache.xml文件:
一切都运作得几乎完美。标准查询被缓存,并且当其他集群成员上的记录被修改时,缓存的查询会立即在其他服务器上更新。
然而,我的问题是当插入新记录时,那个表上的缓存查询不知道它,直到缓存查询过期。
我可能在我的EHcache.xml配置中漏掉了某些内容,但我不知道可能是什么。
有任何想法吗?
以下是EHCache.xml文件:
<!--<diskStore path="java.io.tmpdir"/>-->
<!-- means for cache replication -->
<cacheManagerPeerProviderFactory
class="net.sf.ehcache.distribution.jgroups.JGroupsCacheManagerPeerProviderFactory"
properties="connect=
TCP(bind_port=10700):
S3_PING(...):
MERGE2(max_interval=30000;min_interval=10000):
FD_SOCK(start_port=0):
FD(timeout=3000;max_tries=3):
VERIFY_SUSPECT(timeout=1500):
BARRIER():
pbcast.NAKACK(use_mcast_xmit=false;gc_lag=0;retransmit_timeout=300,600,1200,2400,4800;discard_delivered_msgs=true):
UNICAST(timeout=300,600,1200):
pbcast.STABLE(stability_delay=1000;desired_avg_gossip=50000;max_bytes=400K):
pbcast.GMS(print_local_addr=true;join_timeout=300;view_bundling=true):
FC(max_credits=2M;min_threshold=0.10):
FRAG2(frag_size=60K):
pbcast.STREAMING_STATE_TRANSFER()"
propertySeparator="::" />
<!-- default query cache to be used for all queries without an explicit cache -->
<cache
name="org.hibernate.cache.StandardQueryCache"
maxElementsInMemory="100"
eternal="false"
timeToLiveSeconds="600"
overflowToDisk="false"
statistics="true">
<cacheEventListenerFactory
class="net.sf.ehcache.distribution.jgroups.JGroupsCacheReplicatorFactory"
properties="replicateAsynchronously=true, replicatePuts=true,
replicateUpdates=true, replicateUpdatesViaCopy=false, replicateRemovals=true" />
</cache>
<!-- timestamps of particular last update time to tables -->
<cache
name="org.hibernate.cache.UpdateTimestampsCache"
maxElementsInMemory="5000"
eternal="true"
overflowToDisk="false"
statistics="true">
<cacheEventListenerFactory
class="net.sf.ehcache.distribution.jgroups.JGroupsCacheReplicatorFactory"
properties="replicateAsynchronously=true, replicatePuts=true,
replicateUpdates=true, replicateUpdatesViaCopy=false, replicateRemovals=true" />
</cache>
<!-- default cache to use for all cacheable entities without an explicit cache -->
<defaultCache
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="600"
timeToLiveSeconds="600"
overflowToDisk="false"
maxElementsOnDisk="10000000"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="600"
memoryStoreEvictionPolicy="LRU"
statistics="true">
<cacheEventListenerFactory
class="net.sf.ehcache.distribution.jgroups.JGroupsCacheReplicatorFactory"
properties="replicateAsynchronously=true, replicatePuts=true,
replicateUpdates=true, replicateUpdatesViaCopy=false, replicateRemovals=true" />
</defaultCache>
`
read-write
而不是nonstrict-read-write
或其他类型吗?在非read-write
缓存上,数据保存可能会延迟。此外,显式刷新缓存也可以帮助解决问题。请务必检查设置。 - mico