Package org.apache.ibatis.cache
Interface Cache
- 
- All Known Implementing Classes:
- BlockingCache,- FifoCache,- LoggingCache,- LruCache,- PerpetualCache,- ScheduledCache,- SerializedCache,- SoftCache,- SynchronizedCache,- TransactionalCache,- WeakCache
 
 public interface CacheSPI for cache providers.One instance of cache will be created for each namespace. The cache implementation must have a constructor that receives the cache id as an String parameter. MyBatis will pass the namespace as id to the constructor. public MyCache(final String id) { if (id == null) { throw new IllegalArgumentException("Cache instances require an ID"); } this.id = id; initialize(); }- Author:
- Clinton Begin
 
- 
- 
Method SummaryAll Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidclear()Clears this cache instance.StringgetId()ObjectgetObject(Object key)default ReadWriteLockgetReadWriteLock()Optional.intgetSize()Optional.voidputObject(Object key, Object value)ObjectremoveObject(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.
 
- 
- 
- 
Method Detail- 
getIdString getId() - Returns:
- The identifier of this cache
 
 - 
putObjectvoid putObject(Object key, Object value) - Parameters:
- key- Can be any object but usually it is a- CacheKey
- value- The result of a select.
 
 - 
getObjectObject getObject(Object key) - Parameters:
- key- The key
- Returns:
- The object stored in the cache.
 
 - 
removeObjectObject removeObject(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. 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.- Parameters:
- key- The key
- Returns:
- Not used
 
 - 
clearvoid clear() Clears this cache instance.
 - 
getSizeint getSize() Optional. This method is not called by the core.- Returns:
- The number of elements stored in the cache (not its capacity).
 
 - 
getReadWriteLockdefault ReadWriteLock getReadWriteLock() Optional. As of 3.2.6 this method is no longer called by the core.Any locking needed by the cache must be provided internally by the cache provider. - Returns:
- A ReadWriteLock
 
 
- 
 
-