如何实现自填充EHcache? [英] How to implement Self Populating EHcache?
问题描述
您能给我一些实现SelfPouplatingEhcache的步骤吗。
Could you please give me the steps to implement SelfPouplatingEhcache.
问候,
Raju
Regards, Raju
推荐答案
SelfPopulatingCache
充当另一个 EhCache
。当您向 SelfPopulatingCache
请求缓存的值,并且该值不在基础缓存中时, SelfPopulatingCache
将创建为您的价值。它使用您还提供的 CacheEntryFactory
来完成此操作。
SelfPopulatingCache
acts as a wrapper (or decorator) around another instance of EhCache
. When you ask the SelfPopulatingCache
for a cached value, and that value is not in the underlying cache, the SelfPopulatingCache
will create the value for you. It does this using the CacheEntryFactory
that you also provide.
因此要创建 SelfPopulatingCache
,则需要:
-
EhCache的实例
,您可以从ChacheManager
中获取 -
CacheEntryFactory
的实例,
- An instance of
EhCache
, which you fetch from theChacheManager
- An instance of
CacheEntryFactory
, which you write yourself.
将它们都传递给 SelfPopulatingCache
的构造函数,然后你在那里。
Pass them both to the constructor of SelfPopulatingCache
, and there you are.
这篇关于如何实现自填充EHcache?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!