是否可以使用Ehcache缓存服务器并使用blockingCache进行配置?我似乎无法找到如何在ehcache.xml文件中配置它...只能以编程方式.
要通过ehcache.xml将BlockingCache用作缓存的默认装饰器,首先应该实现自己的CacheDecoratorFactory,比如它的DefaultCacheDecoratorFactory:
public class DefaultCacheDecoratorFactory extends CacheDecoratorFactory {
@Override
public Ehcache createDecoratedEhcache(Ehcache cache, Properties properties) {
return new BlockingCache(cache);
}
@Override
public Ehcache createDefaultDecoratedEhcache(Ehcache cache, Properties properties) {
return new BlockingCache(cache);
}
}
Run Code Online (Sandbox Code Playgroud)
然后将其配置为缓存定义的一部分,如下所示:
<cache name="CACHE_NAME" more values here.../>
<cacheDecoratorFactory class="whatsoever.DefaultCacheDecoratorFactory"/>
</cache>
Run Code Online (Sandbox Code Playgroud)
并使用cacheManager.getEhCache()来访问cacheManager.getCache()以外的缓存,因为它只为装饰缓存返回null.
| 归档时间: |
|
| 查看次数: |
1953 次 |
| 最近记录: |