Ehcache(2.9.x) - API Developer Guide, Blocking and Self Populating Caches
About Blocking and Self-Populating Caches
The net.sf.ehcache.constructs package contains some applied caching classes which use the core classes to solve everyday caching problems. Two of these are BlockingCache and SelfPopulatingCache.
Blocking Cache
Imagine you have a very busy web site with thousands of concurrent users. Rather than being evenly distributed in what they do, they tend to gravitate to popular pages. These pages are not static, they have dynamic data which goes stale in a few minutes. Or imagine you have collections of data which go stale in a few minutes. In each case the data is extremely expensive to calculate. If each request thread asks for the same thing, that is a lot of work. Now, add a cache. Get each thread to check the cache; if the data is not there, go and get it and put it in the cache.
Now, imagine that there are so many users contending for the same data that in the time it takes the first user to request the data and put it in the cache, ten other users have done the same thing. The upstream system, whether a JSP or velocity page, or interactions with a service layer or database are doing ten times more work than they need to. Enter the BlockingCache. It is blocking because all threads requesting the same key wait for the first thread to complete. Once the first thread has completed the other threads simply obtain the cache entry and return. The BlockingCache can scale up to very busy systems. Each thread can either wait indefinitely, or you can specify a timeout using the timeoutMillis constructor argument.
For more information, see the Javadoc for BlockingCache.
SelfPopulatingCache
Sometimes, you want to use the BlockingCache, but the requirement to always release the lock results in complicated code. You also want to think about what you are doing without thinking about the caching. Enter the SelfPopulatingCache.
SelfPopulatingCache is synonymous with pull-through cache, which is a common caching term. However, SelfPopulatingCache is always used in addition to a BlockingCache.
SelfPopulatingCache uses a CacheEntryFactory which, given a key, knows how to populate the entry.
Note: JCache inspired getWithLoader and getAllWithLoader directly in Ehcache, which work with a CacheLoader may be used as an alternative to SelfPopulatingCache.
For more information, see the Javadoc for SelfPopulatingCache.
Ehcache(2.9.x) - API Developer Guide, Blocking and Self Populating Caches的更多相关文章
- Ehcache(2.9.x) - API Developer Guide, Cache Extensions
About Cache Extensions Cache extensions are a general-purpose mechanism to allow generic extensions ...
- Ehcache(2.9.x) - API Developer Guide, Key Classes and Methods
About the Key Classes Ehcache consists of a CacheManager, which manages logical data sets represente ...
- Ehcache(2.9.x) - API Developer Guide, Write-Through and Write-Behind Caches
About Write-Through and Write-Behind Caches Write-through caching is a caching pattern where writes ...
- Ehcache(2.9.x) - API Developer Guide, Cache Eviction Algorithms
About Cache Eviction Algorithms A cache eviction algorithm is a way of deciding which element to evi ...
- Ehcache(2.9.x) - API Developer Guide, Basic Caching
Creating a CacheManager All usages of the Ehcache API start with the creation of a CacheManager. The ...
- Ehcache(2.9.x) - API Developer Guide, Cache Usage Patterns
There are several common access patterns when using a cache. Ehcache supports the following patterns ...
- Ehcache(2.9.x) - API Developer Guide, Searching a Cache
About Searching The Search API allows you to execute arbitrarily complex queries against caches. The ...
- Ehcache(2.9.x) - API Developer Guide, Using Explicit Locking
About Explicit Locking Ehcache contains an implementation which provides for explicit locking, using ...
- Ehcache(2.9.x) - API Developer Guide, Transaction Support
About Transaction Support Transactions are supported in versions of Ehcache 2.0 and higher. The 2.3. ...
随机推荐
- 终于吧Appserv搞通了
.在学习php的时候遇到了这个问题; 1.Fatal error: Call to undefined function set_magic_quotes_runtime() in E:\App 打开 ...
- Unity3D之Mecanim动画系统学习笔记(二):模型导入
我们要在Unity3D中使用上模型和动画,需要经过下面几个阶段的制作,下面以一个人形的模型开发为准来介绍. 模型制作 模型建模(Modelling) 我们的美术在建模时一般会制作一个称为T-Pose( ...
- Linux下修改用户home目录
一般在Linux上新建一个用户,会在/home目录下自动创建一个以用户名命名的home目录 修改linux下用户自动建立的家目录 vi编辑器打开/etc/default/useradd 这个文件,然后 ...
- javabean总结
一. javabean 是什么? Bean的中文含义是“豆子”,顾名思义,JavaBean是指一段特殊的Java类, 就是有默然构造方法,只有get,set的方法的java类的对象. 专业点解释是: ...
- 数据库MySQL常用命令复习
-- 查看数据库 show databases; -- 创建数据库 create database '数据库名'; -- 删除数据库 drop database '数据库名'; -- 选库 use ' ...
- 图片攻击-BMP图片中注入恶意JS代码 <转载>
昨天看到一篇文章<hacking throung images>,里面介绍了如何在BMP格式的图片里注入JS代码,使得BMP图片既可以正常显示, 也可以运行其中的JS代码,觉得相当有趣. ...
- Hyper-V网络配置
Hyper-V虚拟交换机类型应用: 外部虚拟网络: 可以实现虚拟机之间.虚拟机和物理机.虚拟机和外部网络的通信. 生产环境不勾选“允许管理操作系统共享此网络适配器”,勾选之后会为主机创建虚拟网卡,会实 ...
- 【HMTL】3D标签球
这是一个3D TAG 在网站展示中是个不错的东东,能让人眼前一亮,值得收藏. 这个是效果: 源码下载: 点 击 下 载
- Note of IOS 7 - Views
1. Views presentation: A view (an object whose class is UIView or a subclass of UIView) knows how to ...
- phpcms v9和discuz X3.1实现同步登陆退出论坛(已实现)
网络上文章很多,按步骤配置好了之后phpcms可以同步登录dz,但是dz登录后状态却无法同步到phpcms,网络上找了很多资料都大同小异,头大.只能自己调试了,废话不多说了. 以下网络上抄 ...