繁体   English   中英

Spring Ehcache不被使用

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM