hibernate开启二级缓存
一、在hibernate.cfg.xml中加入:
<!-- 开启二级缓存 -->
<property name="hibernate.cache.use_query_cache">true</property>
<property name="cache.use_second_level_cache">true</property>
<property name="cache.provider_class">
org.hibernate.cache.EhCacheProvider</property>
二、在src目录下加入ehcache.xml文件,文件内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<ehcache>
<diskStore path="java.io.tmpdir"/>
<defaultCache
maxElementsInMemory="150000"
eternal="true"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
overflowToDisk="true"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
/>
</ehcache>
三、在需要从缓存读数据的DAO查询代码中加入setCacheable(true)。
转载于:https://blog.51cto.com/7229277/1336212
hibernate开启二级缓存相关推荐
- 【SSH网上商城项目实战16】Hibernate的二级缓存处理首页的热门显示
转自:https://blog.csdn.net/eson_15/article/details/51405911 网上商城首页都有热门商品,那么这些商品的点击率是很高的,当用户点击某个热门商品后需要 ...
- hibernate教程--二级缓存详解
Hibernate的二级缓存 一.缓存概述 缓存(Cache): 计算机领域非常通用的概念.它介于应用程序和永久性数据存储源(如硬盘上的文件或者数据库)之间,其作用是降低应用程序直接读写永久性数据存储 ...
- hibernate的二级缓存
缓存(Cache): 计算机领域非常通用的概念.它介于应用程序和永久性数据存储源(如硬盘上的文件或者数据库)之间,其作用是降低应用程序直接读写永久性数据存储源的频率,从而提高应用的运行性能.缓存中的数 ...
- Hibernate中二级缓存配置
实体类 : 1 package cn.happy.entity; 2 public class Emp { 3 private Integer empNo; 4 private String empN ...
- 不要依赖hibernate的二级缓存
一.hibernate的二级缓存 如果开启了二级缓存,hibernate在执行任何一次查询的之后,都会把得到的结果集放到缓存中,缓存结构可以看作是一个hash table,key是数据库记录的 ...
- redis作为hibernate的二级缓存
hibernate的二级缓存有好多,像ehcache.不过项目的缓存使用的是redis,而redis官方没有实现hibernate的二级缓存接口,只得自己实现.看看公司的高手如何做的吧. 先看配置: ...
- MyBatis 缓存详解-什么时候开启二级缓存?
一级缓存默认是打开的,二级缓存需要配置才可以开启.那么我们必须思考一个问题,在什么情况下才有必要去开启二级缓存? 1.因为所有的增删改都会刷新二级缓存,导致二级缓存失效,所以适合在查询为主的应用中使用 ...
- (转)为Spring集成的Hibernate配置二级缓存
http://blog.csdn.net/yerenyuan_pku/article/details/52896195 前面我们已经集成了Spring4.2.5+Hibernate4.3.11+Str ...
- tkmybatis开启二级缓存
1.MyBatis配置文件开启二级缓存功能 <settings> <settingname="cacheEnabled"value="true" ...
最新文章
- React useState,useEffect ,Hook是什么?什么是副作用?
- 【STM32】程序下载(ST-LINK V2)
- 使用CLion的时候,对于cmake的使用
- Django之model模型
- php 比较字符串或文章的相似度
- dumpbin.exe
- 拦截器RetryAndFollowUpInterceptor分析
- redis.conf
- Frame Stacking 框架堆叠
- 凸优化第六章逼近与拟合 6.2 最小范数问题
- Python的函数理解外传
- Machine Learning Regression-Case Study
- matlab fisher检验,模式识别中Fisher分类器的Matlab实现及测试
- 如何快速撰写文章—伪原创
- 时间复杂度与大O记法的理解
- 云计算技术 — 多云
- 我所看过的n部动漫(n=23)
- 修改ETM,用Ogre实现《天龙八部》地形与部分场景详解(附源码)
- waterdrop(token方式)连接星环科技云平台tdc(kerberos认证)
- 工作就是不让自己闲着