gpt4 book ai didi

hibernate - 如何获取 grails hibernate L2 缓存统计信息?

转载 作者:行者123 更新时间:2023-12-02 14:03:27 25 4
gpt4 key购买 nike

grails hibernate L2 缓存统计 - net.sf.ehcache.Statistics

我将 ehcache 与我的 L2 缓存一起使用。

我想分析性能并从 net.sf.ehcache.Statistics 获取统计信息。
没有任何成功,我一直在寻找一种从 Grails 或 Spring 访问 L2 缓存管理器的方法。

我很感激任何提示。

波纹管是使用的典型 hibernate 设置

hibernate {

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
}

最佳答案

您可以获取sessionFactory通过将其注入(inject)您的服务,然后 enable statistics在上面:

class My Service {

def sessionFactory

def myMethod() {
// Enable stats
Statistics stats = sessionFactory.getStatistics();
stats.setStatisticsEnabled(true);

// Do some querying and analyse the stats

}

}

关于hibernate - 如何获取 grails hibernate L2 缓存统计信息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11621495/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com