知道什么时候触击数据库vs缓存 [英] Knowing when hitting database vs cache

查看:93
本文介绍了知道什么时候触击数据库vs缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑到Hibernate的所有智慧以及各种缓存策略,我如何知道某个操作是导致物理数据库命中还是来自缓存?

开发期间进行一些配置文件调整整个事情,直到获得预期的行为为止。要激活缓存日志记录,请修改日志级别,例如使用 log4j.xml 时:

 < logger name =org.hibernate.cache> 
< level value =DEBUG/>
< / logger>

请注意,我建议 在生产平台上使用它可能非常冗长,因此可能会减慢执行速度)。

欲了解更多详情,请参阅记录文档。


Given all the smarts around Hibernate and it's various caching strategies, how do I know if a certain operation is resulting in a physical database hit, or coming from the cache?

解决方案

Traditionally, you'll use Hibernate built-in cache logging and do some profiling during development to tune the whole thing until you get the expected behavior. To activate the cache logging, alter the log level, for example when using a log4j.xml:

<logger name="org.hibernate.cache">
   <level value="DEBUG" />
</logger>

Note that I do not recommend using this on the production platform (it may be very verbose and thus may slow down the execution).

For more details, refer to the Logging of the documentation.

这篇关于知道什么时候触击数据库vs缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆