- java.lang.Object
-
- org.mybatis.caches.ehcache.AbstractEhcacheCache
-
- All Implemented Interfaces:
org.apache.ibatis.cache.Cache
- Direct Known Subclasses:
EhBlockingCache,EhcacheCache
public abstract class AbstractEhcacheCache extends Object implements org.apache.ibatis.cache.Cache
Cache adapter for Ehcache.- Author:
- Simone Tripodi
-
-
Field Summary
Fields Modifier and Type Field Description protected net.sf.ehcache.EhcachecacheThe cache instance.protected static net.sf.ehcache.CacheManagerCACHE_MANAGERThe cache manager reference.protected StringidThe cache id (namespace).
-
Constructor Summary
Constructors Constructor Description AbstractEhcacheCache(String id)Instantiates a new abstract ehcache cache.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()booleanequals(Object obj)StringgetId()ObjectgetObject(Object key)ReadWriteLockgetReadWriteLock()intgetSize()inthashCode()voidputObject(Object key, Object value)ObjectremoveObject(Object key)voidsetMaxEntriesLocalDisk(long maxEntriesLocalDisk)Sets the maximum number elements on Disk.voidsetMaxEntriesLocalHeap(long maxEntriesLocalHeap)Sets the maximum objects to be held in memory (0 = no limit).voidsetMemoryStoreEvictionPolicy(String memoryStoreEvictionPolicy)Sets the eviction policy.voidsetTimeToIdleSeconds(long timeToIdleSeconds)Sets the time to idle for an element before it expires.voidsetTimeToLiveSeconds(long timeToLiveSeconds)Sets the time to idle for an element before it expires.StringtoString()voidunlock(Object key)
-
-
-
Field Detail
-
CACHE_MANAGER
protected static net.sf.ehcache.CacheManager CACHE_MANAGER
The cache manager reference.
-
id
protected final String id
The cache id (namespace).
-
cache
protected net.sf.ehcache.Ehcache cache
The cache instance.
-
-
Constructor Detail
-
AbstractEhcacheCache
public AbstractEhcacheCache(String id)
Instantiates a new abstract ehcache cache.- Parameters:
id- the chache id (namespace)
-
-
Method Detail
-
clear
public void clear()
- Specified by:
clearin interfaceorg.apache.ibatis.cache.Cache
-
getId
public String getId()
- Specified by:
getIdin interfaceorg.apache.ibatis.cache.Cache
-
getObject
public Object getObject(Object key)
- Specified by:
getObjectin interfaceorg.apache.ibatis.cache.Cache
-
getSize
public int getSize()
- Specified by:
getSizein interfaceorg.apache.ibatis.cache.Cache
-
putObject
public void putObject(Object key, Object value)
- Specified by:
putObjectin interfaceorg.apache.ibatis.cache.Cache
-
removeObject
public Object removeObject(Object key)
- Specified by:
removeObjectin interfaceorg.apache.ibatis.cache.Cache
-
unlock
public void unlock(Object key)
-
getReadWriteLock
public ReadWriteLock getReadWriteLock()
- Specified by:
getReadWriteLockin interfaceorg.apache.ibatis.cache.Cache
-
setTimeToIdleSeconds
public void setTimeToIdleSeconds(long timeToIdleSeconds)
Sets the time to idle for an element before it expires. Is only used if the element is not eternal.- Parameters:
timeToIdleSeconds- the default amount of time to live for an element from its last accessed or modified date
-
setTimeToLiveSeconds
public void setTimeToLiveSeconds(long timeToLiveSeconds)
Sets the time to idle for an element before it expires. Is only used if the element is not eternal.- Parameters:
timeToLiveSeconds- the default amount of time to live for an element from its creation date
-
setMaxEntriesLocalHeap
public void setMaxEntriesLocalHeap(long maxEntriesLocalHeap)
Sets the maximum objects to be held in memory (0 = no limit).- Parameters:
maxEntriesLocalHeap- The maximum number of elements in heap, before they are evicted (0 == no limit)
-
setMaxEntriesLocalDisk
public void setMaxEntriesLocalDisk(long maxEntriesLocalDisk)
Sets the maximum number elements on Disk. 0 means unlimited.- Parameters:
maxEntriesLocalDisk- the maximum number of Elements to allow on the disk. 0 means unlimited.
-
setMemoryStoreEvictionPolicy
public void setMemoryStoreEvictionPolicy(String memoryStoreEvictionPolicy)
Sets the eviction policy. An invalid argument will set it to null.- Parameters:
memoryStoreEvictionPolicy- a String representation of the policy. One of "LRU", "LFU" or "FIFO".
-
-