1 分布式缓存
目的:将缓存数据进行分布式的管理
作用:通过mybatis和ehcache整合,可以把缓存数据的管理托管ehcache
在mybatis中提供一个cache接口,只要实现cache接口就可以把缓存数据灵活的管理起来。
2 整合步骤
下载jar包
配置ehcache.xml
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../config/ehcache.xsd">
<!--diskStore:缓存数据持久化的目录 地址 -->
<diskStore path="F:\develop\ehcache" />
<defaultCache
maxElementsInMemory="1000"
maxElementsOnDisk="10000000"
eternal="false"
overflowToDisk="false"
diskPersistent="true"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
diskExpiryThreadIntervalSeconds="120"
memoryStoreEvictionPolicy="LRU">
</defaultCache>
</ehcache>
Mapper中使用ehcache的缓存
也可以实现个性化配置