我想在我的spring mvc web應用程序中使用ehcache。因爲我的服務器每天都會重置,因此我希望緩存是永久的。我是否將它保存在硬路徑中?和鋤保存它? 謝謝。如何在spring中使用ehcache永久緩存mvc
在我的調度員servlet.xml中我添加此
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">
<property name="cacheManager" ref="ehcache"/>
</bean>
<bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
<property name="configLocation" value="classpath:ehcache.xml"/>
<property name="shared" value="true"/>
</bean>
和我ehcach.xml是
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd">
<diskStore path="c:/tmp"/>
<defaultCache
maxElementsInMemory="500" eternal="true" overflowToDisk="false" memoryStoreEvictionPolicy="LFU"/>
<cache name="mycache"
maxElementsInMemory="0"
eternal="true"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
overflowToDisk="true"
maxElementsOnDisk="10000000"
diskPersistent="true"
diskExpiryThreadIntervalSeconds="1200"
memoryStoreEvictionPolicy="LRU">
[1] <persistence strategy="localRestartable" synchronousWrites="false" />
</cache>
我添加此[1],直到緩存是永久性的,後服務器重置不是remove.but發生此異常元素不允許嵌套元素。 還我使用ehcach-core2.7.0.jar
Element <cache> does not allow nested <persistence> elements.
緩存數據保存在哪裏?我使用 來保存它,但是在緩存之後它的大小爲零。 –
ali
2014-11-05 06:06:41
你需要發佈一個完整的工作示例供人檢查。這些信息不足以評論正在發生的事情和原因。 – manish 2014-11-05 07:44:11
我編輯我的問題。 – ali 2014-11-05 08:20:48