【发布时间】:2014-04-21 06:15:49
【问题描述】:
我已经浏览了这个博客以使用 grails 中的二级缓存
& 我做了以下更改
在 resources.groovy 中
userCache(
org.springframework.cache.ehcache.EhCacheFactoryBean) {
}
内部服务类
def userCache
public def userCachedList(){
if (userCache.get("userList")) {
...
}
else {
...
userCache.put(
new net.sf.ehcache.Element("userList",
list)
)
}
...
}
缓存工作正常,但此缓存列表存储在物理位置的问题。当我启动应用程序时,我看到 .ehcache-diskstore.lock 在 tmp 目录中创建。
我的设置是
hibernate {
cache.use_second_level_cache = false
cache.use_query_cache = false
//cache.use_structured_entities = false
cache.provider_class = 'net.sf.ehcache.hibernate.EhCacheProvider'
hibernate.format_sql=false
hibernate.connection.release_mode='after_transaction'
}
ehcache.xml 是
<ehcache name="myapp">
<!-- Necessary for spring-security-acl plugin-->
<!--<diskStore path="java.io.tmpdir"/>-->
<defaultCache
maxElementsInMemory="20000"
eternal="false"
timeToIdleSeconds="3600"
timeToLiveSeconds="3600"
overflowToDisk="false">
<!-- <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"/> -->
</defaultCache>
<cache
name="owsoo.User"
maxEntriesLocalHeap="50"
eternal="false"
timeToLiveSeconds="600"
overflowToDisk="false">
<!-- <cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"/> -->
</cache>
<cache name="aclCache"
maxElementsInMemory="100000"
eternal="true"
overflowToDisk="false"
memoryStoreEvictionPolicy="LRU"
statistics="true"
/>
要使用内存缓存而不是物理磁盘存储,我需要更改哪些设置?
【问题讨论】:
标签: grails grails-orm ehcache