是否可以使用Ehcache Cache Server並使用blockingCache配置它?我似乎無法找到如何配置這個在ehcache.xml文件中...只能以編程方式。Ehcache緩存服務器+ BlockingCache?
2
A
回答
1
你可以聲明編程裝飾緩存,而且在配置,請參閱: http://ehcache.org/documentation/apis/cache-decorators#by-configuration
你需要添加一個net.sf.ehcache.constructs.CacheDecoratorFactory實現,做你所需要的。我想你可能會對傳遞給net.sf.ehcache.constructs.CacheDecoratorFactory#createDecoratedEhcache的Ehcache實例進行一些模式匹配,並返回null或由BlockingCache裝飾的緩存實例。
儘管如此,謹慎的做法是確保在未命中時,您總是在處將放回緩存中,否則將不會解鎖該密鑰/段的寫入鎖定。
6
要使用BlockingCache爲通過ehcache.xml中緩存的缺省裝飾,首先應該實現自己的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);
}
}
然後將其配置爲緩存定義的一部分,這樣的:
<cache name="CACHE_NAME" more values here.../>
<cacheDecoratorFactory class="whatsoever.DefaultCacheDecoratorFactory"/>
</cache>
並採用cacheManager.getEhCache()來訪問比cacheManager.getCache()以外的緩存,因爲它只返回null您的裝修緩存。
相關問題
- 1. 集中緩存服務器。 (Ehcache或Hazelcast)
- 2. 的Ehcache與事務緩存
- 3. 緩存命中(ehCache)
- 4. 如何在Ehcache服務器的情況下使用緩存寫入器和緩存加載器
- 5. WCF緩存服務器端
- 6. 服務器端緩存
- 7. Apache Web服務器緩存
- 8. Windows服務器AppFabric緩存
- 9. Silverstripe - Restful服務器緩存
- 10. 服務器緩存IIS6
- 11. 使用ehcache緩存java.util.Map
- 12. Ehcache中的緩存失效
- 13. Spring 3.1緩存註解EhCache
- 14. EhCache不更新緩存
- 15. ehcache緩存命中性能
- 16. OpenJPA緩存vs ehcache插件
- 17. 配置ehCache:緩存爲空
- 18. ASP.NET服務器端緩存生存期?
- 19. 清除Apache服務器內存緩存
- 20. 清除遠程服務器的ehcache
- 21. 緩存Web服務
- 22. 在Appfabric緩存中製作服務器主管服務器
- 23. nodejs服務器中的API服務器和緩存問題
- 24. 緩存支出:移動服務器與服務器開發
- 25. 大內存是否恭維EhCache&Terracotta服務器?
- 26. 啓動pentaho雙服務器緩存
- 27. Laravel - 服務器無法設置緩存
- 28. 刪除蟒蛇HTTP服務器緩存
- 29. SQL服務器 - 緩存內的功能
- 30. 刷新PHP服務器緩存