Spring框架中的cachedecorator SelfPopulatingCache的ehcache.xml配置

时间:2015-03-10 12:52:58

标签: spring caching decorator ehcache

经过对ehcache的一些研究后,我们发现'net.sf.ehcache.constructs.blocking.UpdatingSelfPopulatingCache'是我们要求的最佳匹配。

我遵循了论坛帖子(https://sourceforge.net/forum/message.php?msg_id=7382649)中给出的建议,并意识到我只能通过编程方式在CacheManager上使用辅助方法替换装饰缓存和实际的ehcache。

我想问的问题是,使用ehcache.xml文件,我能够描述我想在系统中使用的所有Ehcaches。我觉得在XML本身中也可以直观地声明ehcache装饰器,这样我就可以在一个地方完全集中我的所有配置。即ehcache XML。有没有办法可以在ehcache.xml本身中为装饰器添加配置?

2 个答案:

答案 0 :(得分:1)

我找到了一个使用cusom缓存装饰器的好例子

Specifying global EhCache capacity

 <cache name="singleSharedCache" maxElementsInMemory="2000"
   eternal="false" overflowToDisk="false">
<cacheDecoratorFactory class="com.xyz.util.CustomEhcacheDecoratorFactory"
    properties="name=org.hibernate.tutorial.domain.Person" />
<cacheDecoratorFactory class="com.xyz.util.CustomEhcacheDecoratorFactory"
    properties="name=org.hibernate.tutorial.domain.Event" />
</cache>

答案 1 :(得分:0)

您应该在cache decorators documentation

中找到有关此内容的所有信息

确实可以从XML声明修饰的缓存。

相关问题