缓存ecache使用
1、配置ecache.xml文件内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<ehcache name="es">
<diskStore path="java.io.tmpdir"/>
<!-- 字典项缓存-->
<cache name="dictCache"
maxEntriesLocalHeap="5000"
eternal="true"
overflowToDisk="false"
statistics="true">
</cache>
</ehcache>
注释:<diskStore path="java.io.tmpdir"/>代表默认临时文件路径 user.home 代表用户主目录 user.dir 代表当前工作目录
2、springmvc配置文件中添加如下配置:
<!-- 字典项缓存管理-->
<bean id="cacheManagerFactory"
class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
<property name="configLocation">
<value>classpath:ehcache/ehcache.xml</value>
</property>
</bean>
<!-- 声明cacheManager -->
<bean class="org.springframework.cache.ehcache.EhCacheCacheManager">
<property name="cacheManager" ref="cacheManagerFactory"></property>
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余3页未读,立即下载