using ehcache blocking decorator with hibernate

夙愿已清 提交于 2019-12-08 05:57:55

问题


I'm using ehcache with hibernate and I'd like to use the blocking or SelfPopulating cache to avoid the issues presented in http://ehcache.org/documentation/constructs-0_5.html#mozTocId722946

An expensive operation is required, say rendering a large web page, which takes 30 seconds. The page is not considered stale until it is 5 minutes old. The page is hit very heavily and will be hit an average of 20 times per minute each 5 minutes.

Do I have to do this programmatically as http://ehcache.org/documentation/cache_decorators.html suggests or is there a declarative (in xml) way to do so?

thanks a lot


回答1:


There is no way to do this in ehcache.xml since you must register the class with the CacheManager before the cache config is read.

So you must use the code mentioned in the docs and you must run this code before you do anything with Hibernate. A simple way to do this is to use the hibernate.cache.provider_class property which tells Hibernate a factory for the cache. Have a look at the source of an implementation which should give you an idea what you need to do.



来源:https://stackoverflow.com/questions/1518808/using-ehcache-blocking-decorator-with-hibernate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!