[英]Multiple caches not workig in Spring EhCache
在我的代碼中,我在Spring MVC中添加了EhCache。 我已經聲明了兩個緩存名稱,其中一個緩存正在工作,而另一個不在工作。 我在這里附加了我的ehcache.xml
<defaultCache eternal="false"
maxElementsInMemory="1000" overflowToDisk="false" diskPersistent="false"
timeToIdleSeconds="0" timeToLiveSeconds="600"
memoryStoreEvictionPolicy="LRU"/>
<cache name="pp" eternal="false"
maxElementsInMemory="500" overflowToDisk="false" diskPersistent="false"
timeToIdleSeconds="3600" timeToLiveSeconds="3600"
memoryStoreEvictionPolicy="LRU" />
<cache name="cc" eternal="false"
maxElementsInMemory="500" overflowToDisk="false" diskPersistent="false"
timeToIdleSeconds="3600" timeToLiveSeconds="3600"
memoryStoreEvictionPolicy="LRU" />
這是我的Java代碼:
@Cacheable(value="pp")
public Result getPlayers() throws Exception {
HttpGet httpGet = new HttpGet(PLAYERS_URL);
LOGGER.info("PLAYERS_URL {}", URL);
ResponseHandler<String> responseHandler = new BasicResponseHandler();
String response = httpClient.execute(httpGet, responseHandler);
Result result = omapper.readValue(response, Result.class);
return result;
}
只有cc在工作。 任何幫助,將不勝感激。
我能夠找到它的根本原因並解決了這個問題。 我聲明為@Cacheable的方法具有一些本地調用,這意味着同一服務類中的一個方法正在調用它。 當我從本地類中刪除該呼叫時,它工作正常。 這可能對其他人有用。
謝謝,
開發
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.