首页 新闻 会员 周边

关于Ehcache中的flush问题请教

1
悬赏园豆:20 [待解决问题]

各位大神,本人想在Web容器关闭时(即ServletContextListener的contextDestroyed方法中)将Ehcache缓存flush到磁盘上,等到下次启动时,重新启用这些数据,但是现在死活无法成功,请大家指教。以下是具体的代码和配置情况:

1、代码:

 1 private void shutdownEhcache()
 2     {
 3         Cache groupChatHistoryCache = CacheManager.create().getCache("GroupChatHistoryCache");
 4         Cache personChatHistoryCache = CacheManager.create().getCache("PersonChatHistoryCache");
 5 
 6         groupChatHistoryCache.flush();
 7         personChatHistoryCache.flush();
 8 
 9         CacheManager.create().shutdown();
10 
11         LOG.debug("Ehcache has been shut down");
12     }

2、Ehcache配置

 1     <!-- Group Chat History Cache Config -->
 2     <cache name="GroupChatHistoryCache"
 3             maxElementsInMemory="1000"
 4             eternal="true"
 5             overflowToDisk="true"
 6             diskPersistent="true"
 7             memoryStoreEvictionPolicy="LRU"
 8             transactionalMode="off"
 9             />
10     
11     <!-- Person Chat History Cache Config -->
12     <cache name="PersonChatHistoryCache"
13             maxElementsInMemory="100"
14             eternal="true"
15             overflowToDisk="true"
16             diskPersistent="true"
17             memoryStoreEvictionPolicy="LRU"
18             transactionalMode="off"
19             />

 

3、.data和.index文件(Tomcat Stop了之后)

正如上面的截图,两个缓存的Data文件始终为0,不知道为什么?!

 

这个问题纠缠很久了,真心请各位大神帮帮忙,谢谢!

BODAO的主页 BODAO | 初学一级 | 园豆:182
提问于:2015-06-29 09:37
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册