读书人

hiberante二级缓存1(配置)

发布时间: 2012-10-17 10:25:46 作者: rapoo

hiberante二级缓存一(配置)
都说hibernate的二级缓存用处比较大,在一年前的一个项目时就打算使用hibernate的二级缓存,但时常碰到脏读又没时间进行分析和处理,后来决定项目取消了对二级缓存的使用。 前不久公司发钱请了红帽的高级架构师进行培训,再三强调二级缓存的作用。。。今天终于下定决心进行了一些测试。首先进行hibernate的二级缓存配置
第一步:.hibernate.cfg.xml 配置文件



第二步:定义Attachment.hbm.xml 在xml开始部分定义二级缓存


第三步:定义ehcache.xml文件
<ehcache>    <diskStore path="c:\\ehcache\"/>    <defaultCache        maxElementsInMemory="10000"        eternal="false"        timeToIdleSeconds="120"        timeToLiveSeconds="120"        overflowToDisk="true"        />    <cache name="com.going.oa.model.Attachment"        maxElementsInMemory="10000"        eternal="false"        timeToIdleSeconds="300"        timeToLiveSeconds="600"        overflowToDisk="true"        />  </ehcache>

读书人网 >软件架构设计

热点推荐