用ehcache做缓存,如果断电后要自动加载之前缓存,要怎么配置,一直不行啊?

Posted on

用ehcache做缓存,如果断电后要自动加载之前缓存,要怎么配置,一直不行啊?

当前访客身份:游客 [ 登录 | 加入开源中国 ]

当前位置:讨论区 » 技术问答 » EhCache

软件 代码 讨论区 新闻 博客 zwt

用ehcache做缓存,如果断电后要自动加载之前缓存,要怎么配置,一直不行啊?

zwt 发表于 5-3 13:09 5个月前, 4回/600阅, 最后回答: 1个月前 讨论区 » 技术问答

【杭州】开源中国-源创会第十三期开始报名 我要报名» 在使用ehcache 如果碰到意外情况,断电或服务器挂掉,我希望重启后 ehcache 能自动加载之前的缓存,但一直试都不行,不知道要怎么配置;

目前在重启服务器的时候会提示:

警告: The index for data file stake.data is out of date, probably due to an unclean shutdown. Deleting index file stake.index

目前配置: view sourceprint?

01

<

diskStore

path

=

"java.io.tmpdir"

/>

02

03

<

defaultCache

04

maxElementsInMemory

=

"10000" 05

eternal

=

"false"

06

timeToIdleSeconds

=

"43200" 07

timeToLiveSeconds

=

"43200"

08

overflowToDisk

=

"true" 09

diskPersistent

=

"true"

10

diskExpiryThreadIntervalSeconds

=

"120" 11

memoryStoreEvictionPolicy

=

"LFU"

12

/>

标签: EhCache Java 我想问同样的问题1个人想要问同样的问题 补充话题说明»

分享到 **

收藏 **

6 **

举报 **

0 | 0 **

按评价排序 | 显示最新答案 | 回页面顶部 共有4个答案 我要回答»

  • zwt

zwt 回答于 2012-05-03 13:32

举报 已经解决,在ehcache初始化之前

System.setProperty("net.sf.ehcache.enableShutdownHook","true");

请看 http://stackoverflow.com/questions/2373431/ehcache-disk-store-unclean-shutdown

有帮助(0) | 没帮助(0) | 评论(0) | 引用此答案

  • samsamsam

samsamsam 回答于 2012-05-14 16:29

举报 我想请教,我按照

System.setProperty("net.sf.ehcache.enableShutdownHook","true");

这个方法试过还是The index for data file is out of date。。。。。 --- 共有 1 条评论 ---

  • zwt 你要在加载ehcache之前设置环境变量,设置成功后看会输出log (4个月前 by zwt) 回复

有帮助(0) | 没帮助(0) | 评论(1) | 引用此答案

  • fbfan520

fbfan520 回答于 2012-09-05 14:00

举报 System.setProperty("net.sf.ehcache.enableShutdownHook","true");请问这句加在哪里 --- 共有 1 条评论 ---

  • zwt 在ehcache初始化之前 (1个月前 by zwt) 回复

有帮助(0) | 没帮助(0) | 评论(1) | 引用此答案

  • fbfan520

fbfan520 回答于 2012-09-07 13:35

举报 在ehcache初始化之前是什么意思? public static CacheManager manager = CacheManager.create("D:\XML\ehcache.xml"); public static Cache diskOnlyEternalCache = null; public static Cache diskEternalCache = null; public static Cache disk7DayCache = null; public static Cache diskSyn7DayCache = null; public static Cache disk1DayCache = null;

private CacheManageService() {

}

public synchronized static Cache getDiskOnlyEternalCache() {

    if (diskOnlyEternalCache == null) {
        diskOnlyEternalCache = manager.getCache("diskOnlyEternalCache");
    }
    return diskOnlyEternalCache;
}

像这个程序我加在哪里? 有帮助(0) | 没帮助(0) | 评论(0) | 引用此答案

非会员用户) ")")") 回答案顶部 | 回页面顶部 有什么技术问题吗? 我要提问

全部(3)...zwt的其他问题

© 开源中国社区(OsChina.NET) | 关于我们 | 广告联系 | @新浪微博 | 开源中国手机版 | 粤ICP备12009483号-3

希望本站内容对您有点用处,有什么疑问或建议请在后面留言评论
转载请注明作者(RobinChia)和出处 It so life ,请勿用于任何商业用途