[英]Hibernate cache in grails domain class
I have a domain class in grails 1.5 that represents data from a table that seldom changes. 我在grails 1.5中有一个域类,该域类表示很少更改的表中的数据。 How can I configure hibernate's cache so the class accesses the table let's say only once per hour?
我该如何配置休眠的高速缓存,以使该类每小时访问一次表?
Thanks 谢谢
Drop an ehcache.xml into grails-app/conf. 将ehcache.xml拖放到grails-app / conf中。 You can take one, for instance, from
%grails_home%/lib/ehcache-core-XXX.jar
, ehcache-failsafe.xml. 例如,您可以从
%grails_home%/lib/ehcache-core-XXX.jar
和ehcache-failsafe.xml中获取一个。
In defaultCache tag, put in timeToLiveSeconds="3600"
. 在defaultCache标记中,放入
timeToLiveSeconds="3600"
。
Though, cache won't give you an absolute guarantee - for instance, it won't pre-cache, and some instances can be pushed out. 不过,缓存不会为您提供绝对的保证-例如,它不会进行预缓存,并且某些实例可以推出。
EDIT : In case you're interested in per-class caching strategy, a sample : 编辑 :如果您对每个类的缓存策略感兴趣,请参考以下示例 :
<cache name="org.appfuse.model.User"
eternal="false"
timeToIdleSeconds="3600"
timeToLiveSeconds="3600"
overflowToDisk="false" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.