二级缓存处理大数据 用ehcache.xml配置文件
2014-06-09 19:31
489 查看
![](http://images.cnitblog.com/i/227236/201406/091923012805998.jpg)
二级缓存大量数据的解决方案
数据很大
二级缓存 存储大数据,让 内存和磁盘文件进行交互,数据库中的不变的数据在磁盘上,这样就可以少和数据库进行交互了
ehcache.xml 放在src下
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../config/ehcache.xsd"> <!--存储位置--> <diskStore path="C:\\TEMP1"/> <defaultCache maxElementsInMemory="12" eternal="false" timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="false" maxElementsOnDisk="10000000" diskPersistent="false" diskExpiryThreadIntervalSeconds="120" memoryStoreEvictionPolicy="LRU" /> <Cache name="cn.itcast.hiberate.sh.domain.Classes" <!--针对的类对象,它最好都是不变的 只执行查询语句--> maxElementsInMemory="5" eternal="false" timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true" maxElementsOnDisk="10000000" diskPersistent="false" diskExpiryThreadIntervalSeconds="120" memoryStoreEvictionPolicy="LRU" /> </ehcache>
磁盘和内存进行交互,加快速度
@Test public void testAllClasses(){ Session session = sessionFactory.openSession(); List<Classes> classesList = session.createQuery("from Classes").list(); session.close(); try { Thread.sleep(1000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
在c://Temp1中会多个文件,查询数据库的数据会放在此文件中,以减少和数据库的交互
相关文章推荐
- spring二级缓存的ehcache 的 配置文件
- Dropdownlist统一配置(从xml或枚举读取数据),应用文件依赖缓存.
- ehcache.xml及结合shiro缓存的ehcache的配置文件
- 03_MyBatis基本查询,mapper文件的定义,测试代码的编写,resultMap配置返回值,sql片段配置,select标签标签中的内容介绍,配置使用二级缓存,使用别名的数据类型,条件查询ma
- Hibernate 二级缓存 ehcache.xml 的相关配置的几点问题
- 03_MyBatis基本查询,mapper文件的定义,测试代码的编写,resultMap配置返回值,sql片段配置,select标签标签中的内容介绍,配置使用二级缓存,使用别名的数据类型,条件查询ma
- Hibernate 的 二级缓存——ehcache配置文件
- hibernate.cfg.xml 配置文件 禁用二级缓存
- MyBatis--查询缓存--ehcache二级缓存配置文件详解
- spring ehcache 多个maven module 中多个ehcache.xml 配置文件的处理方式
- mybatis的缓存配置--ehcache.xml(缓存配置文件)
- 利用Spring的AOP来配置和管理你的二级缓存(EHCache)
- 利用Spring的AOP来配置和管理你的二级缓存(EHCache)
- XML配置文件的读取处理
- Hibernate中ehcache二级缓存配置方法
- xml文件处理的好工具--读取数据篇--cnjsp.org
- XML配置文件的读取处理
- 以XML文件存储配置数据的技术实现,c++
- 用Digester处理XML配置文件
- JAVA技术:XML配置文件的读取处理