ITeye博客

EHcache关闭后缓存失效

scholers · 2010-03-16 21:21 · EHCache · 编程语言 · Cache · JVM · QQ · Markdown

最近在研究EHcache,发现很多帖子或者网上的资料,都说EHcache在使用之后要显式的关闭,调用shutdown方法, 可是我在使用之后,发现第二次进入程序的时候,缓存不起作用,还是再次查询了数据库,不知道为什么? 还是我使用的不对呢? 看到HCCACHE的官网也是这么写的: Shutdown the CacheManager ehcache应该在使用后关闭, 最佳实践是在code中显式调用:

Java代码

//Shutdown the singleton CacheManager   
CacheManager.getInstance().shutdown(); 

根据论坛朋友的回答: 在你不需要使用,之前缓存好的数据时关闭

you should call CacheManager.getInstance().shutdown() so that the threads are stopped and cache memory released back to the JVM. Calling shutdown also insures that your persistent disk stores get written to disk in a consistent state and will be usable the next time they are used.

评论(2)

  1. #2 楼 · scholers · 2010-12-14 20:44

    tianhandigeng writes:

    兄弟,我也在使用Ehcache,有很多疑问,可不可以向你请教一下 我qq是874904507

    兄弟我加你了,不过我上班不能上QQ

  2. #1 楼 · tianhandigeng · 2010-12-14 19:48

    兄弟,我也在使用Ehcache,有很多疑问,可不可以向你请教一下 我qq是874904507

评论功能维护中,当前仅展示历史评论。