【发布时间】:2012-07-03 14:13:52
【问题描述】:
我对@987654321@ 比较陌生,并试图在我的应用程序(示例应用程序)中实现缓存。我目前正在尝试使用 RMI 复制对某些数据对象使用缓存复制。我在同一台机器上运行了 2 个 tomcat 实例,并且在两个实例上都部署了相同的应用程序。我已经验证在检索对象缓存时正确命中并且它正在提高性能。
但是当我在第一个实例上创建一个新对象并尝试在第二个实例中检索(有一个列出所有对象的页面)时,不会显示新添加的对象。
我可以看到该对象在第二个实例的缓存中。此外,在日志中也得到了确认,其中我看到了以下消息
2012-07-03 17:06:41,471 [RMI TCP Connection(6)-192.168.100.105] 调试分发。RMICachePeer - 缓存 com.mycompany.session.Session 的 RMICachePeer:远程放置已接收。元素是:[key = com.mycompany.session.Session#10, value=Item{version=0,freshTimestamp=5494027884412928, version=1, hitCount=0, CreationTime = 1341315402000, LastAccessTime = 1341315402000]
以前有没有人见过这种行为,他们可以帮助我了解可能出了什么问题吗?
下面提到的是我的 ehcache.xml 文件的内容
<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ehcache.xsd" >
<diskStore path="D:\\Cache1"/>
<cacheManagerPeerProviderFactory
class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
properties="peerDiscovery=automatic, multicastGroupAddress=230.0.0.1, hostName=192.168.100.105, multicastGroupPort=4446, timeToLive=32"
/>
<cacheManagerPeerListenerFactory
class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
properties="hostName=192.168.100.105, port=40001, socketTimeoutMillis=5000"
/>
<cache name="com.mycompany.session.Session"
maxElementsInMemory="100"
eternal="true"
overflowToDisk="true">
<cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
properties="replicateAsynchronously=false
replicatePutsViaCopy=true,
replicateUpdatesViaCopy=true,
replicatePuts=true,
replicateUpdates=true,
replicateRemovals=true"/>
<bootstrapCacheLoaderFactory
class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory"/>
</cache>
<defaultCache
maxElementsInMemory="100"
eternal="true"
overflowToDisk="true"
/>
</ehcache>
tomcat 的第二个实例也有类似的 ehcache 配置,只是 diskStore 路径是“D://Cache2”,对等侦听器端口是 40002。
感谢您的帮助。
【问题讨论】:
标签: ehcache