public class

CoherenceCacheStrategy

extends Object
implements CacheConcurrencyStrategy
java.lang.Object
   ↳ com.atlassian.confluence.cache.tangosol.hibernate.CoherenceCacheStrategy

Class Overview

This class is a copied from net.sf.hibernate.cache.ReadWriteCache. The difference is that this class doesn't synchronize on a method level and instead of explicitly calling lock->operation->unlock on the underlying cache it makes use of Coherence's com.tangosol.util.InvocableMap.EntryProcessor to reduce the amount of network requests. This implementation only works with the CoherenceInvokableHibernateCache.

Summary

Nested Classes
class CoherenceCacheStrategy.Item An item of cached data, timestamped with the time it was cached,. 
class CoherenceCacheStrategy.Lock A soft lock which supports concurrent locking, timestamped with the time it was released 
interface CoherenceCacheStrategy.Lockable  
Public Constructors
CoherenceCacheStrategy()
Public Methods
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()
void destroy()
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)
void setCache(Cache cache)
void setMinimalPuts(boolean minimalPuts)
void update(Object key, Object value)
Do nothing.
[Expand]
Inherited Methods
From class java.lang.Object
From interface net.sf.hibernate.cache.CacheConcurrencyStrategy

Public Constructors

public CoherenceCacheStrategy ()

Public Methods

public void afterInsert (Object key, Object value, Object version)

Add the new item to the cache, checking that no other transaction has accessed the item.

Throws
CacheException

public 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. Release our lock.

Throws
CacheException

public void clear ()

Throws
CacheException

public void destroy ()

public void evict (Object key)

Do nothing.

Throws
CacheException

public Object get (Object key, long txTimestamp)

Do not return an item whose timestamp is later than the current transaction timestamp. (Otherwise we might compromise repeatable read unnecessarily.) Do not return an item which is soft-locked. Always go straight to the database instead.

Note that since reading an item from that cache does not actually go to the database, it is possible to see a kind of phantom read due to the underlying row being updated after we have read it from the cache. This would not be possible in a lock-based implementation of repeatable read isolation. It is also possible to overwrite changes made and committed by another transaction after the current transaction read the item from the cache. This problem would be caught by the update-time version-checking, if the data is versioned or timestamped.

Throws
CacheException

public void insert (Object key, Object value)

Do nothing.

Throws
CacheException

public CacheConcurrencyStrategy.SoftLock lock (Object key, Object version)

Stop any other transactions reading or writing this item to/from the cache. Send them straight to the database instead. (The lock does time out eventually.) This implementation tracks concurrent locks my transactions which simultaneously attempt to write to an item.

Throws
CacheException

public 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. (Otherwise, a stale item might be re-added if the database is operating in repeatable read isolation mode.)

Throws
CacheException

public void release (Object key, CacheConcurrencyStrategy.SoftLock clientLock)

Release the soft lock on the item. Other transactions may now re-cache the item (assuming that no other transaction holds a simultaneous lock).

Throws
CacheException

public void remove (Object key)

Throws
CacheException

public void setCache (Cache cache)

public void setMinimalPuts (boolean minimalPuts)

Throws
HibernateException

public void update (Object key, Object value)

Do nothing.

Throws
CacheException