Package org.hibernate.cache
Class NonstrictReadWriteCache
java.lang.Object
org.hibernate.cache.NonstrictReadWriteCache
- All Implemented Interfaces:
CacheConcurrencyStrategy
Caches data that is sometimes updated without ever locking the cache.
If concurrent access to an item is possible, this concurrency strategy
makes no guarantee that the item returned from the cache is the latest
version available in the database. Configure your cache timeout accordingly!
This is an "asynchronous" concurrency strategy.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanafterInsert(Object key, Object value, Object version) Do nothing.booleanafterUpdate(Object key, Object value, Object version, SoftLock lock) Invalidate the item (again, for safety).voidclear()Evict all items from the cache immediately.voiddestroy()Clean up all resources.voidInvalidate the itemGet the most recent version, if available.getCache()Get the wrapped cache implementationGet the cache region namebooleanInvalidate the itemDo nothing.booleanput(Object key, Object value, long txTimestamp, Object version, Comparator versionComparator, boolean minimalPut) Add an item to the cache.voidInvalidate the item (again, for safety).voidEvict an item from the cache immediately (without regard for transaction isolation).voidSet the underlying cache implementation.toString()booleanDo nothing.
-
Constructor Details
-
NonstrictReadWriteCache
public NonstrictReadWriteCache()
-
-
Method Details
-
setCache
Description copied from interface:CacheConcurrencyStrategySet the underlying cache implementation.- Specified by:
setCachein interfaceCacheConcurrencyStrategy- Parameters:
cache-
-
getCache
Description copied from interface:CacheConcurrencyStrategyGet the wrapped cache implementation- Specified by:
getCachein interfaceCacheConcurrencyStrategy
-
get
Get the most recent version, if available.- Specified by:
getin interfaceCacheConcurrencyStrategy- Parameters:
key-txTimestamp- a timestamp prior to the transaction start time- Returns:
- the cached object or null
- Throws:
CacheException
-
put
public boolean put(Object key, Object value, long txTimestamp, Object version, Comparator versionComparator, boolean minimalPut) throws CacheException Add an item to the cache.- Specified by:
putin interfaceCacheConcurrencyStrategy- Parameters:
key-value-txTimestamp- a timestamp prior to the transaction start timeversion- the item version numberversionComparator- a comparator used to compare version numbersminimalPut- indicates that the cache should avoid a put is the item is already cached- Returns:
- true if the object was successfully cached
- Throws:
CacheException
-
lock
Do nothing.- Specified by:
lockin interfaceCacheConcurrencyStrategy- Parameters:
key-version-- Returns:
- null, no lock
- Throws:
CacheException
-
remove
Description copied from interface:CacheConcurrencyStrategyEvict an item from the cache immediately (without regard for transaction isolation).- Specified by:
removein interfaceCacheConcurrencyStrategy- Parameters:
key-- Throws:
CacheException
-
clear
Description copied from interface:CacheConcurrencyStrategyEvict all items from the cache immediately.- Specified by:
clearin interfaceCacheConcurrencyStrategy- Throws:
CacheException
-
destroy
public void destroy()Description copied from interface:CacheConcurrencyStrategyClean up all resources.- Specified by:
destroyin interfaceCacheConcurrencyStrategy
-
evict
Invalidate the item- Specified by:
evictin interfaceCacheConcurrencyStrategy- Throws:
CacheException
-
insert
Invalidate the item- Specified by:
insertin interfaceCacheConcurrencyStrategy
-
update
Do nothing.- Specified by:
updatein interfaceCacheConcurrencyStrategy
-
release
Invalidate the item (again, for safety).- Specified by:
releasein interfaceCacheConcurrencyStrategy- Parameters:
key-- Throws:
CacheException
-
afterUpdate
public boolean afterUpdate(Object key, Object value, Object version, SoftLock lock) throws CacheException Invalidate the item (again, for safety).- Specified by:
afterUpdatein interfaceCacheConcurrencyStrategy- Throws:
CacheException
-
afterInsert
Do nothing.- Specified by:
afterInsertin interfaceCacheConcurrencyStrategy- Throws:
CacheException
-
getRegionName
Description copied from interface:CacheConcurrencyStrategyGet the cache region name- Specified by:
getRegionNamein interfaceCacheConcurrencyStrategy
-
toString
-