|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectnet.sf.hibernate.cache.ReadWriteCache
Caches data that is sometimes updated while maintaining the semantics of
"read committed" isolation level. If the database is set to "repeatable
read", this concurrency strategy almost maintains the semantics.
Repeatable read isolation is compromised in the case of concurrent writes.
This is an "asynchronous" concurrency strategy.
If this strategy is used in a cluster, the underlying cache implementation
must support distributed hard locks (which are held only momentarily). This
strategy also assumes that the underlying cache implementation does not do
asynchronous replication and that state has been fully replicated as soon
as the lock is released.
| Nested Class Summary | |
static class |
ReadWriteCache.Item
An item of cached data, timestamped with the time it was cached,. |
static class |
ReadWriteCache.Lock
A soft lock which supports concurrent locking, timestamped with the time it was released |
static interface |
ReadWriteCache.Lockable
|
| Nested classes inherited from class net.sf.hibernate.cache.CacheConcurrencyStrategy |
CacheConcurrencyStrategy.SoftLock |
| Constructor Summary | |
ReadWriteCache()
|
|
| Method Summary | |
void |
afterInsert(Object key,
Object value,
Object version)
Add the new item to the cache, checking that no other transaction has accessed the item. |
void |
afterUpdate(Object key,
Object value,
Object version,
CacheConcurrencyStrategy.SoftLock clientLock)
Re-cache the updated state, if and only if there there are no other concurrent soft locks. |
void |
clear()
Evict all items from the cache immediately. |
void |
destroy()
Clean up all resources. |
void |
evict(Object key)
Do nothing. |
Object |
get(Object key,
long txTimestamp)
Do not return an item whose timestamp is later than the current transaction timestamp. |
void |
insert(Object key,
Object value)
Do nothing. |
CacheConcurrencyStrategy.SoftLock |
lock(Object key,
Object version)
Stop any other transactions reading or writing this item to/from the cache. |
boolean |
put(Object key,
Object value,
long txTimestamp,
Object version,
Comparator versionComparator)
Do not add an item to the cache unless the current transaction timestamp is later than the timestamp at which the item was invalidated. |
void |
release(Object key,
CacheConcurrencyStrategy.SoftLock clientLock)
Release the soft lock on the item. |
void |
remove(Object key)
Evict an item from the cache immediately (without regard for transaction isolation). |
void |
setCache(Cache cache)
Set the underlying cache implementation. |
void |
setMinimalPuts(boolean minimalPuts)
Enable "minimal puts" mode for this cache |
void |
update(Object key,
Object value)
Do nothing. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public ReadWriteCache()
| Method Detail |
public void setCache(Cache cache)
CacheConcurrencyStrategy
setCache in interface CacheConcurrencyStrategycache - public Object get(Object key, long txTimestamp) throws CacheException
get in interface CacheConcurrencyStrategykey - txTimestamp - a timestamp prior to the transaction start time
CacheExceptionpublic CacheConcurrencyStrategy.SoftLock lock(Object key, Object version) throws CacheException
lock in interface CacheConcurrencyStrategykey - version -
CacheExceptionpublic boolean put(Object key, Object value, long txTimestamp, Object version, Comparator versionComparator) throws CacheException
put in interface CacheConcurrencyStrategykey - value - txTimestamp - a timestamp prior to the transaction start timeversion - the version number of the object we are puttingversionComparator - a Comparator to be used to compare version numbers
CacheExceptionpublic void release(Object key, CacheConcurrencyStrategy.SoftLock clientLock) throws CacheException
release in interface CacheConcurrencyStrategykey -
CacheException
public void clear()
throws CacheException
CacheConcurrencyStrategy
clear in interface CacheConcurrencyStrategyCacheExceptionpublic void remove(Object key) throws CacheException
CacheConcurrencyStrategy
remove in interface CacheConcurrencyStrategykey -
CacheExceptionpublic void destroy()
CacheConcurrencyStrategy
destroy in interface CacheConcurrencyStrategypublic void afterUpdate(Object key, Object value, Object version, CacheConcurrencyStrategy.SoftLock clientLock) throws CacheException
afterUpdate in interface CacheConcurrencyStrategyCacheExceptionpublic void afterInsert(Object key, Object value, Object version) throws CacheException
afterInsert in interface CacheConcurrencyStrategyCacheExceptionpublic void evict(Object key) throws CacheException
evict in interface CacheConcurrencyStrategyCacheExceptionpublic void insert(Object key, Object value) throws CacheException
insert in interface CacheConcurrencyStrategyCacheExceptionpublic void update(Object key, Object value) throws CacheException
update in interface CacheConcurrencyStrategyCacheException
public void setMinimalPuts(boolean minimalPuts)
throws HibernateException
CacheConcurrencyStrategy
setMinimalPuts in interface CacheConcurrencyStrategyHibernateException
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||