【发布时间】:2016-12-21 21:04:12
【问题描述】:
在我的代码中,我使用 EhCache 来存储一个对象。代码如下
@Resource(name = "ehCacheManager")
private CacheManager manager;
private Ehcache cache;
public void testCache(){
cache = manager.getCache("ehSubjects");
for loop to read subjects data{ //This loops runs 15051 times
final Element element = new Element(subject.subjectId(), subject);
cache.put(element);
}
}
System.out.println("Cache Size:"+cache.getSize()); //15000
问题是有 15051 个主题对象,但是当循环之后我尝试打印缓存大小时,它总是给我 15000。
那么我们可以在 EhCache 中保留的对象数量是否有限制?
【问题讨论】:
-
请为 Ehcache 添加任何相关的配置信息。否则很难回答。