Class TransactionalCache
- java.lang.Object
-
- org.apache.ibatis.cache.decorators.TransactionalCache
-
- All Implemented Interfaces:
Cache
public class TransactionalCache extends java.lang.Object implements Cache
The 2nd level cache transactional buffer.This class holds all cache entries that are to be added to the 2nd level cache during a Session. Entries are sent to the cache when commit is called or discarded if the Session is rolled back. Blocking cache support has been added. Therefore any get() that returns a cache miss will be followed by a put() so any lock associated with the key can be released.
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
clearOnCommit
private Cache
delegate
private java.util.Set<java.lang.Object>
entriesMissedInCache
private java.util.Map<java.lang.Object,java.lang.Object>
entriesToAddOnCommit
private static Log
log
-
Constructor Summary
Constructors Constructor Description TransactionalCache(Cache delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clears this cache instance.void
commit()
private void
flushPendingEntries()
java.lang.String
getId()
java.lang.Object
getObject(java.lang.Object key)
int
getSize()
Optional.void
putObject(java.lang.Object key, java.lang.Object object)
java.lang.Object
removeObject(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.private void
reset()
void
rollback()
private void
unlockMissedEntries()
-
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
-
-
-
-
Field Detail
-
log
private static final Log log
-
delegate
private final Cache delegate
-
clearOnCommit
private boolean clearOnCommit
-
entriesToAddOnCommit
private final java.util.Map<java.lang.Object,java.lang.Object> entriesToAddOnCommit
-
entriesMissedInCache
private final java.util.Set<java.lang.Object> entriesMissedInCache
-
-
Constructor Detail
-
TransactionalCache
public TransactionalCache(Cache delegate)
-
-
Method Detail
-
getId
public java.lang.String getId()
-
getSize
public int getSize()
Description copied from interface:Cache
Optional. This method is not called by the core.
-
getObject
public java.lang.Object getObject(java.lang.Object key)
-
putObject
public void putObject(java.lang.Object key, java.lang.Object object)
-
removeObject
public java.lang.Object removeObject(java.lang.Object key)
Description copied from interface:Cache
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.- Specified by:
removeObject
in interfaceCache
- Parameters:
key
- The key- Returns:
- Not used
-
clear
public void clear()
Description copied from interface:Cache
Clears this cache instance.
-
commit
public void commit()
-
rollback
public void rollback()
-
reset
private void reset()
-
flushPendingEntries
private void flushPendingEntries()
-
unlockMissedEntries
private void unlockMissedEntries()
-
-