最近在研究EHcache,发现很多帖子或者网上的资料,都说EHcache在使用之后要显示的关闭,调用shutdown方法,
可是我在使用之后,发现第二次进入程序的时候,缓存不起作用,还是再次查询了数据库,不知道为什么?
还是我使用的不对呢?
:o :o 在你不需要使用 之前缓存好的数据时。 :o
Lz看一下shutdown()的目的:
[quote]
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.
[/quote]
Lz 问题说得不是很清楚,
显示调用CacheManager.getInstance().shutdown()关闭EHcache。
详细请参考 :
http://blog.csdn.net/mgoann/archive/2009/04/20/4094963.aspx
http://blog.csdn.net/mgoann/archive/2009/04/20/4095155.aspx
http://blog.csdn.net/mgoann/archive/2009/04/22/4099190.aspx
有一系列的好文章。
[list]
[*]a program exists normally. e.g. System.exit() is called, or the last non-daemon thread exits
[*]the Virtual Machine is terminated. e.g. CTRL-C. This corresponds to kill -SIGTERM pid or kill -15 pid on Unix systems.
[/list]
!! 上面两个时候是自动调用shutdow().