不经常变化的信息 例如客户信息等放入spring cache 使用情况并不多
ehcache.xml
<cache
name="andCache"
timeToIdleSeconds="600"
timeToLiveSeconds="1200"
maxElementsInMemory="10000"
eternal="false"
overflowToDisk="true"
maxElementsOnDisk="10000000"
diskPersistent="false"
memoryStoreEvictionPolicy="LFU" />
/>
spring配置
<cache:annotation-driven cache-manager="cacheManager"/>
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager" p:cache-manager-ref="ehcache" />
<bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" p:shared="true" p:config-location="classpath:/ehcache.xml" />
<!--
<bean id="cacheManager" class="org.springframework.cache.support.SimpleCacheManager">
<property name="caches">
<set>
<bean
class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean"
p:name="default" />
<bean
class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean"
p:name="andCache" />
</set>
</property>
</bean> -->
本文介绍如何在Spring框架中使用EhCache作为缓存组件,并提供了ehcache.xml配置文件示例。通过配置,可以指定缓存项的生命周期、内存中最大元素数量等参数。
947

被折叠的 条评论
为什么被折叠?



