Ehcache配置问题(密钥****的元素为空)

时间:2013-01-12 18:24:01

标签: java hibernate ehcache

我的Ehcache配置存在很大问题。

我用:

  • ehcache 2.6.2
  • hibernate 3.3.1 GA

我目前的配置是:

1)休眠

<bean id="hibernateProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean"> 
  <property name="properties">
    <props> 
       <prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop> 
       <prop key="hibernate.default_schema">@db.schema@</prop> 
       <prop key="hibernate.show_sql">false</prop> 
       <prop key="connection.pool_size">10</prop> 
       <prop key="hibernate.jdbc.batch_size">30</prop> 
       <prop key="hibernate.default_batch_fetch_size">30</prop> 
       <prop key="hibernate.max_fetch_depth">30</prop> 
       <prop key="hibernate.cache.use_second_level_cache">true</prop> 
       <prop key="hibernate.cache.use_query_cache">true</prop> 
       <prop key="hibernate.cache.region.factory_class"> 
          net.sf.ehcache.hibernate.SingletonEhCacheRegionFactory 
       </prop> 
       <prop key="net.sf.ehcache.configurationResourceName"> 
         /ehcache-config.xml 
       </prop> 
       <prop key="hibernate.generate_statistics">true</prop> 
     </props> 
  </property> 
</bean> 

2)ehcache-config.xml

<ehcache name="xxxx"> 

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

<defaultCache 
  maxElementsInMemory="10000" 
  eternal="false" 
  timeToIdleSeconds="120" 
  timeToLiveSeconds="120" 
  overflowToDisk="true" 
  maxElementsOnDisk="10000000" 
  diskPersistent="false" 
  diskExpiryThreadIntervalSeconds="120" 
  memoryStoreEvictionPolicy="LRU" 
 /> 

 <cache name="org.hibernate.cache.UpdateTimestampsCache" 
   maxEntriesLocalHeap="5000" 
   eternal="true"> 
   <persistence strategy="localTempSwap"/> 
 </cache> 

 <cache name="org.hibernate.cache.StandardQueryCache" 
   maxElementsInMemory="10000" 
   eternal="false" 
   timeToIdleSeconds="120" 
   timeToLiveSeconds="120" 
   overflowToDisk="false" 
   diskExpiryThreadIntervalSeconds="120"> 
   <persistence strategy="localTempSwap"/> 
 </cache> 

 </ehcache> 

所有java对象都实现Serializable,我使用读写缓存,所有查询都是setCacheable(true),但我仍然看不到性能改进。

首先,我有很多这样的消息:

 19:30:51,829 DEBUG [Segment] fault added 0 on disk 
 19:30:51,829 DEBUG [Segment] put added 0 on heap 
 19:30:51,829 DEBUG [Segment] fault removed 0 from heap 
 19:30:51,829 DEBUG [Segment] fault added 0 on disk 
 19:30:51,829 DEBUG [Segment] put added 0 on heap 
 19:30:51,830 DEBUG [Segment] fault removed 0 from heap 
 19:30:51,830 DEBUG [Segment] fault added 0 on disk 

我注意到的最重要的事情是:所有使用缓存的尝试都以:

结束
 1) 19:30:47,396 DEBUG [EhcacheGeneralDataRegion] Element for key sql: **** is null

 2) 20:26:31,939 DEBUG [EhcacheGeneralDataRegion] key: ****
    20:26:31,939 DEBUG [EhcacheGeneralDataRegion] Element for key **** is null 

感谢您的协助。

最好的问候。

0 个答案:

没有答案