我正在使用Grails 2.1.0。我一直在尝试验证/配置我的L2缓存。现在,我怀疑休眠/缓存设置是否正确。
hibernate {
generate_statistics = true
cache.use_second_level_cache = true
cache.use_query_cache = true
cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
format_sql = true
use_sql_comments = true
}
package com.att.failbox.log.cause
class LogCauseMemento {
Date dateCreated
static mapping = {
version false
id generator: 'assigned'
table 'log_cause'
cache: true
}
}
<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ehcache.xsd" >
<diskStore path="java.io.tmpdir"/>
<cacheManagerEventListenerFactory class="" properties=""/>
<defaultCache
eternal="false"
timeToLiveSeconds="3600"
overflowToDisk="false"
diskPersistent="false"
/>
<cache name="com.att.failbox.log.cause.LogCauseMemento"
maxElementsInMemory="100000"
eternal="true"
/>
</ehcache>
import org.hibernate.stat.Statistics
class DomainProfilerService {
def sessionFactory
def displayStatistics() {
Statistics stats = sessionFactory.getStatistics()
def names = stats.getSecondLevelCacheRegionNames()
names.each(){ println it }
}
}