简体   繁体   English

EhCache中的不可修改的缓存

[英]Unmodifiable Cache in EhCache

I recently learned about Unmodifiable Map that returns an unmodifiable copy of the Map. 我最近了解了不可修改的地图,该地图返回了不可修改的地图副本。 Is there any such implementation that prevents the modification of data of Cache entries in EhCache? 有没有这样的实现方式可以防止修改EhCache中的Cache条目的数据?

There is no out of the box support for a read-only Cache in Ehcache 2.x or 3.x as I understand your request. 据我了解您的请求,Ehcache 2.x或3.x中没有对只读 Cache的现成支持。

In Ehcache 2.x you could roll your own by using a cache decorator and then making them available to the CacheManager by using CacheManager.addDecoratedCache 在2.X的Ehcache您可以通过推出自己的使用缓存装饰 ,然后使它们提供给CacheManager使用CacheManager.addDecoratedCache

In Ehcache 3.x there is no built-in support for decorated caches, so you would have to handle that yourself. 在Ehcache 3.x中,没有对修饰后的缓存的内置支持,因此您必须自己处理。 Note that anyway since there is no longer a CacheManager singleton, this is not as bad as it sounds with regards to the way you would share the decorated cache with your application components. 请注意,无论如何,由于不再有CacheManager单例,因此与您与应用程序组件共享装饰的缓存的方式相比,听起来还不错。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM