0 0

Ehcache缓存警告问题?10

请教各位,我在spring+hibernate里配置Ehcache缓存,出现以下警告,请问是什么原因呢?

警告: Creating a new instance of CacheManager using the diskStorePath "D:\Apache Tomcat 6.0.18\temp" which is already used by an existing CacheManager.
The source of the configuration was classpath.
The diskStore path for this CacheManager will be set to D:\Apache Tomcat 6.0.18\temp\ehcache_auto_created_1262783591937.
To avoid this warning consider using the CacheManager factory methods to create a singleton CacheManager or specifying a separate ehcache configuration (ehcache.xml) for each CacheManager instance.

applicationContext.xml里

<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>

ehcache.xml里

<ehcache>
<diskStore path="java.io.tmpdir" />
<defaultCache maxElementsInMemory="10000" eternal="false"
  timeToIdleSeconds="60" timeToLiveSeconds="60" overflowToDisk="true"
  diskSpoolBufferSizeMB="30" maxElementsOnDisk="1000000"
  diskPersistent="false" diskExpiryThreadIntervalSeconds="60"
  memoryStoreEvictionPolicy="LRU" />
</ehcache>
2010年1月06日 21:41

1个答案 按时间排序 按投票排序

0 0

采纳的答案

说下自己的经历吧 : 我之前是只写了自己的 缓存.没有写 默认的

<?xml version="1.0" encoding="UTF-8"?>
<ehcache>

	<diskStore path="java.io.tmpdir" />

<!-- 
name: Cache的唯一标识.
maxElementsInMemory: 内存中最大缓存对象数. 
maxElementsOnDisk: 磁盘中最大缓存对象数, 若是0表示无穷大.
eternal: Element 是否永久有效, 一但设置了, timeout 将不起作用.
overflowToDisk: 当内存中 Element 数量达到 maxElementsInMemory 时, Ehcache 是否将 Element 写到磁盘中.
timeToIdleSeconds:  设置 Element 在失效前的允许闲置时间. 仅当 element 不是永久有效时使用, 
					可选属性, 默认为 0 : 表示可闲置时间无穷大.
timeToLiveSeconds:  设置 Element 在失效前允许存活时间. 最大时间介于创建时间和失效时间之间. 
					仅当 Element 不是永久有效时使用, 默认为 0 : 表示存活时间无穷大.
diskPersistent: 是否缓存虚拟机重启期数据. (一直没明白这个虚拟机是指什么).
diskExpiryThreadIntervalSeconds: 磁盘失效线程运行时间间隔, 默认是 120 秒.
diskSpoolBufferSizeMB: 这个参数设置 DiskStore(磁盘缓存) 的缓存区大小. 默认 30MB.
memoryStoreEvictionPolicy:  当达到 maxElementsInMemory 限制时, Ehcache 将会根据指定的策略去清理内存. 
							默认策略是 LRU(最近最少使用). 可以设置为 FIFO(先进先出) 或 LFU(较少使用).
-->
	<cache name="sampleCache1" maxElementsInMemory="10000" eternal="false" 
		timeToIdleSeconds="300" timeToLiveSeconds="600" overflowToDisk="true" />

</ehcache>


启动的时候报没有默认缓存配置的 WARN , 后来加上就好了
<defaultCache
   maxElementsInMemory="10000"
   eternal="false"
   timeToIdleSeconds="120"
   timeToLiveSeconds="120"
   overflowToDisk="true"
   diskPersistent="false"
   diskExpiryThreadIntervalSeconds="120"
   memoryStoreEvictionPolicy="LRU" />

2010年1月07日 10:41

相关推荐

Global site tag (gtag.js) - Google Analytics