Class BlockingCache
- java.lang.Object
-
- org.apache.ibatis.cache.decorators.BlockingCache
-
- All Implemented Interfaces:
Cache
public class BlockingCache extends java.lang.Object implements Cache
Simple blocking decorator Simple and inefficient version of EhCache's BlockingCache decorator. It sets a lock over a cache key when the element is not found in cache. This way, other threads will wait until this element is filled instead of hitting the database.- Author:
- Eduardo Macarron
-
-
Constructor Summary
Constructors Constructor Description BlockingCache(Cache delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clears this cache instance.java.lang.StringgetId()java.lang.ObjectgetObject(java.lang.Object key)intgetSize()Optional.longgetTimeout()voidputObject(java.lang.Object key, java.lang.Object value)java.lang.ObjectremoveObject(java.lang.Object key)As of 3.3.0 this method is only called during a rollback for any previous value that was missing in the cache.voidsetTimeout(long timeout)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.ibatis.cache.Cache
getReadWriteLock
-
-
-
-
Constructor Detail
-
BlockingCache
public BlockingCache(Cache delegate)
-
-
Method Detail
-
getId
public java.lang.String getId()
-
getSize
public int getSize()
Description copied from interface:CacheOptional. This method is not called by the core.
-
putObject
public void putObject(java.lang.Object key, java.lang.Object value)
-
getObject
public java.lang.Object getObject(java.lang.Object key)
-
removeObject
public java.lang.Object removeObject(java.lang.Object key)
Description copied from interface:CacheAs of 3.3.0 this method is only called during a rollback for any previous value that was missing in the cache. This lets any blocking cache to release the lock that may have previously put on the key. A blocking cache puts a lock when a value is null and releases it when the value is back again. This way other threads will wait for the value to be available instead of hitting the database.- Specified by:
removeObjectin interfaceCache- Parameters:
key- The key- Returns:
- Not used
-
clear
public void clear()
Description copied from interface:CacheClears this cache instance.
-
getTimeout
public long getTimeout()
-
setTimeout
public void setTimeout(long timeout)
-
-