[英]Spring ehcache not beeing use
我正在嘗試為我的MVC頁面設置一個簡單的Spring緩存ehcache。 但是似乎從未使用過緩存。 我的函數每次執行。
@Cacheable(value="newsDocuments",key="#category")
public List<ProcessedDocument> getDocuments(String category, int limit){
List<ProcessedDocument> list = new ArrayList<ProcessedDocument>();
System.out.println("getDocumetns!" + DateTime.now());
list = getDBStuff(category,limit);
return list;
}
ehcache.xml中
<?xml version="1.0" encoding="UTF-8"?>
<ehcache>
<diskStore path="java.io.tmpdir" />
<defaultCache maxElementsInMemory="100" eternal="false"
timeToIdleSeconds="10000" timeToLiveSeconds="60000" overflowToDisk="false" />
<cache name="newsDocuments" timeToIdleSeconds="10000" timeToLiveSeconds="60000" maxElementsInMemory="10" eternal="false" overflowToDisk="false" />
</ehcache>
春天的配置文件
@DynamoDBTable(tableName="ProcessedDocuments")
public class ProcessedDocument implements Serializable {
//Just contains some simple get and set methods.
}
每次執行getDocuments時,它都會調用db並輸出一個新的“ getDocumetns!”。 +控制台中的DateTime.now()。
我在調試中看到的唯一“奇怪”是
DEBUG: net.sf.ehcache.config.ConfigurationHelper - CacheDecoratorFactory not configured. Skipping for 'newsDocuments'.
DEBUG: net.sf.ehcache.config.ConfigurationHelper - CacheDecoratorFactory not configured for defaultCache. Skipping for 'newsDocuments'.
INFO : org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'mvc-dispatcher': initialization completed in 875 ms
我在這里基本缺少什么嗎?
我在找你並用Google搜索它。我從Mkyong Ehcache示例中找到了一個示例;
http://www.mkyong.com/spring/spring-caching-and-ehcache-example/
我認為這對您有用。 因為您的ehcache.xml:與Mkyong的示例ehcache.xml類似。
希望對您有用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.