|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface CacheConcurrencyStrategy
Implementors manage transactional access to cached data. Transactions pass in a timestamp indicating transaction start time. Two different implementation patterns are provided for.
lock(java.lang.Object, java.lang.Object)
-> evict(java.lang.Object)
-> release(java.lang.Object, org.hibernate.cache.access.SoftLock)
lock(java.lang.Object, java.lang.Object)
-> update(java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object)
-> afterUpdate(java.lang.Object, java.lang.Object, java.lang.Object, org.hibernate.cache.access.SoftLock)
insert(java.lang.Object, java.lang.Object, java.lang.Object)
-> afterInsert(java.lang.Object, java.lang.Object, java.lang.Object)
lock(java.lang.Object, java.lang.Object)
-> evict(java.lang.Object)
-> release(java.lang.Object, org.hibernate.cache.access.SoftLock)
Note that, for an asynchronous cache, cache invalidation must be a two
step process (lock->release, or lock-afterUpdate), since this is the only
way to guarantee consistency with the database for a nontransactional cache
implementation. For a synchronous cache, cache invalidation is a single
step process (evict, or update). Hence, this interface defines a three
step process, to cater for both models.
Note that query result caching does not go through a concurrency strategy; they
are managed directly against the underlying cache regions
.
Method Summary | |
---|---|
boolean |
afterInsert(Object key,
Object value,
Object version)
Deprecated. Called after an item has been inserted (after the transaction completes), instead of calling release(). |
boolean |
afterUpdate(Object key,
Object value,
Object version,
SoftLock lock)
Deprecated. Called after an item has been updated (after the transaction completes), instead of calling release(). |
void |
clear()
Deprecated. Evict all items from the cache immediately. |
void |
destroy()
Deprecated. Clean up all resources. |
void |
evict(Object key)
Deprecated. Called after an item has become stale (before the transaction completes). |
Object |
get(Object key,
long txTimestamp)
Deprecated. Attempt to retrieve an object from the cache. |
Cache |
getCache()
Deprecated. Get the wrapped cache implementation |
String |
getRegionName()
Deprecated. Get the cache region name |
boolean |
insert(Object key,
Object value,
Object currentVersion)
Deprecated. Called after an item has been inserted (before the transaction completes), instead of calling evict(). |
SoftLock |
lock(Object key,
Object version)
Deprecated. We are going to attempt to update/delete the keyed object. |
boolean |
put(Object key,
Object value,
long txTimestamp,
Object version,
Comparator versionComparator,
boolean minimalPut)
Deprecated. Attempt to cache an object, after loading from the database. |
void |
release(Object key,
SoftLock lock)
Deprecated. Called when we have finished the attempted update/delete (which may or may not have been successful), after transaction completion. |
void |
remove(Object key)
Deprecated. Evict an item from the cache immediately (without regard for transaction isolation). |
void |
setCache(Cache cache)
Deprecated. Set the underlying cache implementation. |
boolean |
update(Object key,
Object value,
Object currentVersion,
Object previousVersion)
Deprecated. Called after an item has been updated (before the transaction completes), instead of calling evict(). |
Method Detail |
---|
Object get(Object key, long txTimestamp) throws CacheException
key
- txTimestamp
- a timestamp prior to the transaction start time
CacheException
boolean put(Object key, Object value, long txTimestamp, Object version, Comparator versionComparator, boolean minimalPut) throws CacheException
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
CacheException
SoftLock lock(Object key, Object version) throws CacheException
key
- version
-
CacheException
void evict(Object key) throws CacheException
CacheException
boolean update(Object key, Object value, Object currentVersion, Object previousVersion) throws CacheException
CacheException
boolean insert(Object key, Object value, Object currentVersion) throws CacheException
CacheException
void release(Object key, SoftLock lock) throws CacheException
key
-
CacheException
boolean afterUpdate(Object key, Object value, Object version, SoftLock lock) throws CacheException
CacheException
boolean afterInsert(Object key, Object value, Object version) throws CacheException
CacheException
void remove(Object key) throws CacheException
key
-
CacheException
void clear() throws CacheException
CacheException
void destroy()
void setCache(Cache cache)
cache
- String getRegionName()
Cache getCache()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |