Class EhBlockingCache
java.lang.Object
org.mybatis.caches.ehcache.AbstractEhcacheCache
org.mybatis.caches.ehcache.EhBlockingCache
- All Implemented Interfaces:
org.apache.ibatis.cache.Cache
Cache implementation that wraps Ehcache 2 with
BlockingCache semantics.
BlockingCache acquires a per-key lock when a cache miss occurs so that only one thread computes the missing
value while others block. This prevents cache-stampede on a cold or expired entry.
- Author:
- Iwao AVE!
-
Field Summary
Fields inherited from class AbstractEhcacheCache
cache, CACHE_MANAGER, id -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidrebuildCacheWith(net.sf.ehcache.config.CacheConfiguration newConfig) Removes the existing cache from theCacheManagerand registers a new one built fromnewConfig.removeObject(Object key) Methods inherited from class AbstractEhcacheCache
clear, equals, getId, getObject, getReadWriteLock, getSize, hashCode, putObject, setMaxBytesLocalDisk, setMaxEntriesLocalDisk, setMaxEntriesLocalHeap, setMemoryStoreEvictionPolicy, setTimeToIdleSeconds, setTimeToLiveSeconds, toString, unlock
-
Constructor Details
-
EhBlockingCache
-
-
Method Details
-
removeObject
Description copied from class:AbstractEhcacheCache- Specified by:
removeObjectin interfaceorg.apache.ibatis.cache.Cache- Overrides:
removeObjectin classAbstractEhcacheCache
-
rebuildCacheWith
protected void rebuildCacheWith(net.sf.ehcache.config.CacheConfiguration newConfig) Removes the existing cache from theCacheManagerand registers a new one built fromnewConfig. Subclasses may override this method to apply additional decorators (e.g.BlockingCache).Re-wraps the rebuilt cache in a
BlockingCacheafter replacing it.- Overrides:
rebuildCacheWithin classAbstractEhcacheCache- Parameters:
newConfig- the configuration to use for the replacement cache
-