如何验证Grails2.1.0 Hibernate二级缓存?
我正在使用Grails2.1.0。我一直在尝试验证/配置我的二级缓存。现在,我怀疑hibernate/cache设置是否正确 •我已在conf\DataSource.grooy中的hibernate设置中启用了生成统计信息。 我已在域映射中启用缓存。 •我在ehcache.xml中添加了相应的域条目如何验证Grails2.1.0 Hibernate二级缓存?,hibernate,grails,ehcache,Hibernate,Grails,Ehcache,我正在使用Grails2.1.0。我一直在尝试验证/配置我的二级缓存。现在,我怀疑hibernate/cache设置是否正确 •我已在conf\DataSource.grooy中的hibernate设置中启用了生成统计信息。 我已在域映射中启用缓存。 •我在ehcache.xml中添加了相应的域条目 我在找正确的位置来验证我的二级缓存吗?@Joel谢谢Joel,你是对的。结肠是个问题。我还认为,将Groovy1.8与Grails2.1.0结合使用也可能会导致这个问题。再次感谢你,萨米 hiber
我在找正确的位置来验证我的二级缓存吗?@Joel谢谢Joel,你是对的。结肠是个问题。我还认为,将Groovy1.8与Grails2.1.0结合使用也可能会导致这个问题。再次感谢你,萨米
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 }
}
}