Class NonStrictAccessDelegate
- java.lang.Object
-
- org.infinispan.hibernate.cache.commons.access.NonStrictAccessDelegate
-
- All Implemented Interfaces:
AccessDelegate
public class NonStrictAccessDelegate extends Object implements AccessDelegate
Access delegate that relaxes the consistency a bit: stale reads are prohibited only after the transaction commits. This should also be able to work with async caches, and that would allow the replication delay even after the commit.- Author:
- Radim Vansa <rvansa@redhat.com>
-
-
Field Summary
Fields Modifier and Type Field Description protected InfinispanDataRegion
region
protected org.infinispan.functional.FunctionalMap.ReadWriteMap<Object,Object>
writeMap
-
Constructor Summary
Constructors Constructor Description NonStrictAccessDelegate(InfinispanDataRegion region, Comparator versionComparator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
afterInsert(Object session, Object key, Object value, Object version)
Called after an item has been inserted (after the transaction completes), instead of calling release().boolean
afterUpdate(Object session, Object key, Object value, Object currentVersion, Object previousVersion, org.hibernate.cache.spi.access.SoftLock lock)
Called after an item has been updated (after the transaction completes), instead of calling release().void
evict(Object key)
Forcibly evict an item from the cache immediately without regard for transaction isolation.void
evictAll()
Forcibly evict all items from the cache immediately without regard for transaction isolation.Object
get(Object session, Object key, long txTimestamp)
protected Object
getVersion(Object value)
boolean
insert(Object session, Object key, Object value, Object version)
Called after an item has been inserted (before the transaction completes), instead of calling evict().boolean
putFromLoad(Object session, Object key, Object value, long txTimestamp, Object version)
Attempt to cache an object, after loading from the database.boolean
putFromLoad(Object session, Object key, Object value, long txTimestamp, Object version, boolean minimalPutOverride)
Attempt to cache an object, after loading from the database, explicitly specifying the minimalPut behavior.void
remove(Object session, Object key)
Called after an item has become stale (before the transaction completes).void
removeAll()
Called to evict data from the entire regionvoid
unlockItem(Object session, Object key)
Called when we have finished the attempted update/delete (which may or may not have been successful), after transaction completion.boolean
update(Object session, Object key, Object value, Object currentVersion, Object previousVersion)
Called after an item has been updated (before the transaction completes), instead of calling evict().
-
-
-
Field Detail
-
region
protected final InfinispanDataRegion region
-
-
Constructor Detail
-
NonStrictAccessDelegate
public NonStrictAccessDelegate(InfinispanDataRegion region, Comparator versionComparator)
-
-
Method Detail
-
get
public Object get(Object session, Object key, long txTimestamp) throws org.hibernate.cache.CacheException
- Specified by:
get
in interfaceAccessDelegate
- Throws:
org.hibernate.cache.CacheException
-
putFromLoad
public boolean putFromLoad(Object session, Object key, Object value, long txTimestamp, Object version)
Description copied from interface:AccessDelegate
Attempt to cache an object, after loading from the database.- Specified by:
putFromLoad
in interfaceAccessDelegate
- Parameters:
session
- Current sessionkey
- The item keyvalue
- The itemtxTimestamp
- a timestamp prior to the transaction start timeversion
- the item version number- Returns:
- true if the object was successfully cached
-
putFromLoad
public boolean putFromLoad(Object session, Object key, Object value, long txTimestamp, Object version, boolean minimalPutOverride) throws org.hibernate.cache.CacheException
Description copied from interface:AccessDelegate
Attempt to cache an object, after loading from the database, explicitly specifying the minimalPut behavior.- Specified by:
putFromLoad
in interfaceAccessDelegate
- Parameters:
session
- Current session.key
- The item keyvalue
- The itemtxTimestamp
- a timestamp prior to the transaction start timeversion
- the item version numberminimalPutOverride
- Explicit minimalPut flag- Returns:
- true if the object was successfully cached
- Throws:
org.hibernate.cache.CacheException
- Propogated from underlyingRegion
-
insert
public boolean insert(Object session, Object key, Object value, Object version) throws org.hibernate.cache.CacheException
Description copied from interface:AccessDelegate
Called after an item has been inserted (before the transaction completes), instead of calling evict().- Specified by:
insert
in interfaceAccessDelegate
- Parameters:
session
- Current sessionkey
- The item keyvalue
- The itemversion
- The item's version value- Returns:
- Were the contents of the cache actual changed by this operation?
- Throws:
org.hibernate.cache.CacheException
- if the insert fails
-
update
public boolean update(Object session, Object key, Object value, Object currentVersion, Object previousVersion) throws org.hibernate.cache.CacheException
Description copied from interface:AccessDelegate
Called after an item has been updated (before the transaction completes), instead of calling evict().- Specified by:
update
in interfaceAccessDelegate
- Parameters:
session
- Current sessionkey
- The item keyvalue
- The itemcurrentVersion
- The item's current version valuepreviousVersion
- The item's previous version value- Returns:
- Whether the contents of the cache actual changed by this operation
- Throws:
org.hibernate.cache.CacheException
- if the update fails
-
remove
public void remove(Object session, Object key) throws org.hibernate.cache.CacheException
Description copied from interface:AccessDelegate
Called after an item has become stale (before the transaction completes).- Specified by:
remove
in interfaceAccessDelegate
- Parameters:
session
- Current sessionkey
- The key of the item to remove- Throws:
org.hibernate.cache.CacheException
- if removing the cached item fails
-
removeAll
public void removeAll() throws org.hibernate.cache.CacheException
Description copied from interface:AccessDelegate
Called to evict data from the entire region- Specified by:
removeAll
in interfaceAccessDelegate
- Throws:
org.hibernate.cache.CacheException
- if eviction the region fails
-
evict
public void evict(Object key) throws org.hibernate.cache.CacheException
Description copied from interface:AccessDelegate
Forcibly evict an item from the cache immediately without regard for transaction isolation.- Specified by:
evict
in interfaceAccessDelegate
- Parameters:
key
- The key of the item to remove- Throws:
org.hibernate.cache.CacheException
- if evicting the item fails
-
evictAll
public void evictAll() throws org.hibernate.cache.CacheException
Description copied from interface:AccessDelegate
Forcibly evict all items from the cache immediately without regard for transaction isolation.- Specified by:
evictAll
in interfaceAccessDelegate
- Throws:
org.hibernate.cache.CacheException
- if evicting items fails
-
unlockItem
public void unlockItem(Object session, Object key) throws org.hibernate.cache.CacheException
Description copied from interface:AccessDelegate
Called when we have finished the attempted update/delete (which may or may not have been successful), after transaction completion. This method is used by "asynchronous" concurrency strategies.- Specified by:
unlockItem
in interfaceAccessDelegate
key
- The item key- Throws:
org.hibernate.cache.CacheException
- Propogated from underlyingRegion
-
afterInsert
public boolean afterInsert(Object session, Object key, Object value, Object version)
Description copied from interface:AccessDelegate
Called after an item has been inserted (after the transaction completes), instead of calling release(). This method is used by "asynchronous" concurrency strategies.- Specified by:
afterInsert
in interfaceAccessDelegate
key
- The item keyvalue
- The itemversion
- The item's version value- Returns:
- Were the contents of the cache actual changed by this operation?
-
afterUpdate
public boolean afterUpdate(Object session, Object key, Object value, Object currentVersion, Object previousVersion, org.hibernate.cache.spi.access.SoftLock lock)
Description copied from interface:AccessDelegate
Called after an item has been updated (after the transaction completes), instead of calling release(). This method is used by "asynchronous" concurrency strategies.- Specified by:
afterUpdate
in interfaceAccessDelegate
key
- The item keyvalue
- The itemcurrentVersion
- The item's current version valuepreviousVersion
- The item's previous version valuelock
- The lock previously obtained from#lockItem
- Returns:
- Were the contents of the cache actual changed by this operation?
-
-