[英]Spring ehcache not beeing use
I'm trying to setup a simple Spring cache ehcache for my MVC page. 我正在尝试为我的MVC页面设置一个简单的Spring缓存ehcache。 But it seems that the cache is never used. 但是似乎从未使用过缓存。 My function is executed each time. 我的函数每次执行。
@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 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>
spring config file 春天的配置文件
@DynamoDBTable(tableName="ProcessedDocuments")
public class ProcessedDocument implements Serializable {
//Just contains some simple get and set methods.
}
Each time getDocuments is being executed, it calls the db and outputs a new "getDocumetns!" 每次执行getDocuments时,它都会调用db并输出一个新的“ getDocumetns!”。 + DateTime.now() in the console. +控制台中的DateTime.now()。
The only "strange" I see in the debug is 我在调试中看到的唯一“奇怪”是
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
Am I missing something every basic here? 我在这里基本缺少什么吗?
I looked for you and googled it .I found an example from Mkyong Ehcache example ; 我在找你并用Google搜索它。我从Mkyong Ehcache示例中找到了一个示例;
http://www.mkyong.com/spring/spring-caching-and-ehcache-example/ http://www.mkyong.com/spring/spring-caching-and-ehcache-example/
and I think it will useful for you. 我认为这对您有用。 Because your ehcache.xml: not similar Mkyong's example ehcache.xml. 因为您的ehcache.xml:与Mkyong的示例ehcache.xml类似。
I hope it will be useful for you.. 希望对您有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.