如何实现自填充EHcache? [英] How to implement Self Populating EHcache?

查看:71
本文介绍了如何实现自填充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 the ChacheManager
  • An instance of CacheEntryFactory, which you write yourself.

将它们都传递给 SelfPopulatingCache 的构造函数,然后你在那里。

Pass them both to the constructor of SelfPopulatingCache, and there you are.

这篇关于如何实现自填充EHcache?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆