Hibernate 3.5.5,二级缓存配置
实施 Hibernate 监控后,我注意到 hibernate 执行的查询比统计中查询字符串表上的查询多。
统计屏幕截图:
我认为,实现 hibernate 二级缓存,特别是 hibernate 查询缓存可以帮助我减少这种情况查询执行量。
我在网上搜索了一下,发现很多hibernate缓存的provider类。但我没有成功地实现它(infinispan,EhCache)。
我的问题是:
- 您认为,在知道查询字符串表包含更少的查询的情况下,减少查询执行量是最合适的方法吗?
- 您是否有一些使用最新版本的 hibernate(3.5.5 Final)实现二级缓存的示例。
预先感谢您的帮助。
最好的问候,
弗洛伦特,
After implement Hibernate Monitoring, i have noticed that hibernate execute too much query than it have on the query string table in statistics.
Screen-shots of statistics:
I think, implement hibernate 2nd level cache and particularly hibernate query cache help me to reduce this amount of query execute.
I searched on the web, on find many provider class for the cache of hibernate. But I'm not succeeded to implement it (infinispan, EhCache).
My questions are :
- Do you think, it is the most appropriate method to reduce this amount of query execute, knowing that the query string table contains much less query ?
- Do you have some example of implementation of this 2nd level cache with latest version of hibernate (3.5.5 final).
Thank you in advance for you help.
Best regards,
Florent,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这实际上取决于应用程序的类型。数据库在响应这么多查询时是否遇到困难?在网络服务器上添加二级缓存将需要额外的内存。您的网络服务器上有可用的内存吗?
此外,二级缓存对于返回常量/或不经常修改的数据(例如:税率)的查询非常有用。修改较多的数据(例如库存)不应该放入二级缓存。
您在实施过程中遇到了哪些错误? 网络上已经有很多配置。
It really depends on the type of application. Does the DB have trouble responding to this much queries? Adding a second-level cache on your web server will require additional ram. Do you have available ram on the web server?
Additionally, second-level cache is really useful for queries that return constants/or data that are not modified often (ex: taxes rates). Data that are modified a lot (ex. inventory) should not be put in the second-level cache.
What errors did you have in your implementation? There is already a lot of configurations available on the web.