用hibernate使用ehcache阻塞装饰器 [英] using ehcache blocking decorator with hibernate

查看:113
本文介绍了用hibernate使用ehcache阻塞装饰器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在hibernate中使用ehcache,我想使用阻塞或SelfPopulating缓存来避免 http://ehcache.org/documentation/constructs- 0_5.html#mozTocId722946

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


一个昂贵的操作是必需的,比如渲染一个大型网页, 30秒。该网页在5分钟之前才被视为陈旧。这个网页的打击非常严重,每分钟平均每5分钟打20次。

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.

我必须这样做吗?以编程方式 http://ehcache.org/documentation/cache_decorators.html 建议还是有声明式(以xml)的方式来做到这一点?

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?

非常感谢

推荐答案

无法在 ehcache.xml中执行此操作,因为在读取缓存配置之前,您必须使用 CacheManager 注册类。

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.

所以你必须使用文档中提到的代码,并且在你对Hibernate做任何事情之前你必须运行这段代码。一个简单的方法是使用 hibernate.cache.provider_class 属性来告诉Hibernate缓存的工厂。查看应该给出的实施的来源你知道你需要做什么。

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.

这篇关于用hibernate使用ehcache阻塞装饰器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆