Grails中的缓存
我在grails中面临二级缓存的问题 DataSource.groovy FirmClient.groovy FirmClientController.groovy conf/ehcache.xml 第一个问题是在tmpdir中,FirmClient.data没有任何数据。如何将数据转储到FirmClient.data中 第二个问题是,当我第一次命中查询时,使用相同参数的第二次命中的时间(以毫秒为单位)会逐渐减少。但是,如果缓存查询,我认为它应该将时间段显示为零Grails中的缓存,grails,ehcache,Grails,Ehcache,我在grails中面临二级缓存的问题 DataSource.groovy FirmClient.groovy FirmClientController.groovy conf/ehcache.xml 第一个问题是在tmpdir中,FirmClient.data没有任何数据。如何将数据转储到FirmClient.data中 第二个问题是,当我第一次命中查询时,使用相同参数的第二次命中的时间(以毫秒为单位)会逐渐减少。但是,如果缓存查询,我认为它应该将时间段显示为零 有谁能帮助我二级缓存如何工作以及
有谁能帮助我二级缓存如何工作以及如何解决上述问题吗?除非查询返回10000多个maxElementsInMemory元素,否则不会向tmpdir/FirmClient.data写入任何内容。
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = true
cache.provider_class = 'org.hibernate.cache.EhCacheProvider'
}
static mapping = {
cache true
}
def t1 = System.currentTimeMillis()
def firmClient = FirmClient?.findAll(query,[cache:true])
println "time take for Firm client list>>>>>> ${System.currentTimeMillis()-t1}"
<?xml version="1.0" encoding="UTF-8"?>
<ehcache>
<diskStore path="java.io.tmpdir" />
<defaultCache name="default" maxElementsInMemory="10000" eternal="false"
timeToIdleSeconds="300" timeToLiveSeconds="600" overflowToDisk="true"/>
<cache name="FirmClient" maxElementsInMemory="10000" eternal="false"
timeToIdleSeconds="300" timeToLiveSeconds="600" overflowToDisk="true"/>
</ehcache>