Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring cacheDecorator未刷新Ehcache_Spring_Caching_Refresh_Ehcache - Fatal编程技术网

Spring cacheDecorator未刷新Ehcache

Spring cacheDecorator未刷新Ehcache,spring,caching,refresh,ehcache,Spring,Caching,Refresh,Ehcache,我正在使用ehcache从数据库刷新它,但它似乎没有被刷新 ehcache.xml文件-> <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ehcache.xsd" updateCheck="true" monitoring="autodetect" dynamicConfig="true"> <diskStore path="jav

我正在使用ehcache从数据库刷新它,但它似乎没有被刷新

ehcache.xml文件->

<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ehcache.xsd" 
updateCheck="true"
monitoring="autodetect" 
dynamicConfig="true">

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

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

<!-- The cache configuration for our Currency cache -->  
<cache name="cachename"  
    maxElementsInMemory="3000"  
    eternal="false" 
    timeToIdleSeconds="120"  
    timeToLiveSeconds="120"  
    overflowToDisk="true"  
    diskPersistent="false" >
    <persistence strategy="localTempSwap" synchronousWrites="true" />
    <cacheDecoratorFactory class="net.sf.ehcache.constructs.refreshahead.RefreshAheadCacheFactory"
  properties="name=myCacheRefresher,
  timeToRefreshSeconds=180,
  batchSize=10,
  numberOfThreads=4,
  maximumBacklogItems=100,
  evictOnLoadMiss=true" />
</cache>  
</ehcache>  

config.xml

<ehcache:annotation-driven cache-manager="ehcache" />
<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="ehcache.xml" />
</bean>  
<bean id="cachingAttributeSource" class="org.springmodules.cache.annotations.AnnotationCachingAttributeSource" /> 

CatchFetch.java

@GET
@Path("/Mymethod")
@WebMethod(operationName = "mymethodforUI")
public List<Object> mymethodforUI() {

    LOGGER.info("Getting mymethod.");
    return dao.mymethod("keyname");
}
@GET
@路径(“/Mymethod”)
@WebMethod(operationName=“mymethodforUI”)
公共列表mymethodforUI(){
LOGGER.info(“获取我的方法”);
返回dao.mymethod(“keyname”);
}
CacheDAO.java

@Cacheable(value = "cachename", key = "#key")
public List<Object> mymethod(String key) {
    List<Object> res -> a slow query getting from Db
    return res;
}
@Cacheable(value=“cachename”,key=“#key”)
公共列表mymethod(字符串键){
List res->从数据库获取的缓慢查询
返回res;
}
问题1:缓存在前180秒内工作正常,但在180秒后,缓存应该会刷新。这种行为没有得到反映。有人能找出原因吗


问题2:当缓存刷新由cacheDecoratorFactory定义时,是否有任何方法可以记录时间戳?

您是否可以确认没有收到UnsupportedOperationException,声明事务或GAE不支持提前刷新?

为了让提前刷新正常工作,您需要有一个。否则,您希望缓存如何知道如何填充映射


没有加载程序的安装程序可能会引发异常,因为它将无法工作。

否,我不会得到不支持的操作异常您正在使用哪个版本的ehcache?似乎diskPersistent在最近的版本中已被弃用,我看到diskPersistent=“false”>这两个版本都令人困惑