二级缓存插件

二级缓存插件(都有相应的jar包)有:

EhCache:属于后台缓存技术    比较常用   

OSCache:属于页面缓存技术    比较常用

SwarmCache

IBossCache

使用二级缓存插件都要导入相应的jar包后才能使用

ehcache 是缓存小框架 是hibernate采用的默认缓存技术 存取数据 高效   ehcache 是为了重复读取数据 而提供的支持  ehcache 能装各种数据

hibernate缓存又分为一级缓存和二级缓存    二级缓存(SessionFactory:一般情况下:一个SessionFactory对应一个数据库)

开启二级缓存有二种方法:

1.注解:类上加@cache

2.配置:<cache  />  在核心配置文件内copy  hibernate.properties 内对应内容 比如:

<?xml version="1.0" encoding="UTF-8"?>
<ehcache>
  <!-- ehcache 是 缓存工具。 为了重复读取数据 提供支持 ,默认的hibernate的缓存技术.ehcache 能装各种数据-->
  <diskStore path="D:/aaa"/>
  <cache
    name="myCache"
    maxElementsInMemory="2"
    eternal="false"
    timeToIdleSeconds="120"
    timeToLiveSeconds="120"
    overflowToDisk="true"
    diskPersistent="false"
    diskExpiryThreadIntervalSeconds="120"
    memoryStoreEvictionPolicy="LFU"
  />
  <defaultCache
    maxElementsInMemory="10000"
    eternal="false"
    timeToIdleSeconds="120"
    timeToLiveSeconds="120"
    overflowToDisk="true"
    diskPersistent="false"
    diskExpiryThreadIntervalSeconds="120"
    memoryStoreEvictionPolicy="LRU"
    />
</ehcache>

原文地址:https://www.cnblogs.com/hwgok/p/5393861.html