spring 4.1.7和集群ehcache配置可能吗?

时间:2015-07-21 10:42:44

标签: java spring ehcache

我的ehcache配置就像这样开始:

<ehcache   maxBytesLocalHeap="200M" updateCheck="false">

遇到“maxEntriesLocalHeap与高速缓存管理器上设置的maxBytesLocalHeap不兼容”之类的错误后,我查看了spring-context-support的来源:

@SuppressWarnings("deprecation")
    public EhCacheFactoryBean() {
        setMaxEntriesLocalHeap(10000);
        setMaxElementsOnDisk(10000000);
        setTimeToLiveSeconds(120);
        setTimeToIdleSeconds(120);
    }

对setMaxElementsOnDisk的调用如下所示:

void net.sf.ehcache.config.CacheConfiguration.setMaxElementsOnDisk(int maxElementsOnDisk)



Deprecated. use setMaxEntriesLocalDisk(long) for unclustered caches and setMaxEntriesInCache(long) for clustered caches.

Sets the maximum number elements on Disk. 0 means unlimited. 

This property can be modified dynamically while the cache is operating.

Parameters:
maxElementsOnDisk the maximum number of Elements to allow on the disk. 0 means unlimited.

这是否意味着使用spring 4.1.7及其依赖关系ehcache 2.9.1使用spring EhCacheFactoryBean不可能使用集群缓存?

祝你好运, 卡斯滕

2 个答案:

答案 0 :(得分:0)

很抱歉,但我没有看到代码/文档摘要与您的结论之间的链接。你能详细说明吗?

有一件事是,看起来Spring创建的默认缓存与您想要在CacheManager级别执行的操作冲突。但是,如果您不使用默认缓存,则应该没有问题。

答案 1 :(得分:0)

CacheManager和缓存必须使用相同的配置参数maxBytesLocalHeap或maxEntriesLocalHeap,而MaxElements *必须使用不推荐使用