FileDocCategorySizeDatePackage
TransactionalCache.javaAPI DocHibernate 3.2.53697Mon Feb 13 09:57:22 GMT 2006org.hibernate.cache

TransactionalCache

public class TransactionalCache extends Object implements CacheConcurrencyStrategy
Support for fully transactional cache implementations like JBoss TreeCache. Note that this might be a less scalable concurrency strategy than ReadWriteCache. This is a "synchronous" concurrency strategy.
author
Gavin King

Fields Summary
private static final Log
log
private Cache
cache
Constructors Summary
Methods Summary
public booleanafterInsert(java.lang.Object key, java.lang.Object value, java.lang.Object version)
Do nothing.

		return false;
	
public booleanafterUpdate(java.lang.Object key, java.lang.Object value, java.lang.Object version, SoftLock clientLock)
Do nothing.

		return false;
	
public voidclear()

		log.debug( "clearing" );
		cache.clear();
	
public voiddestroy()

		try {
			cache.destroy();
		}
		catch ( Exception e ) {
			log.warn( "could not destroy cache", e );
		}
	
public voidevict(java.lang.Object key)

		cache.remove( key );
	
public java.lang.Objectget(java.lang.Object key, long txTimestamp)

		if ( log.isDebugEnabled() ) {
			log.debug( "cache lookup: " + key );
		}
		Object result = cache.read( key );
		if ( log.isDebugEnabled() ) {
			log.debug( result == null ? "cache miss" : "cache hit" );
		}
		return result;
	
public CachegetCache()

		return cache;
	
public java.lang.StringgetRegionName()


	   
		return cache.getRegionName();
	
public booleaninsert(java.lang.Object key, java.lang.Object value, java.lang.Object currentVersion)

		if ( log.isDebugEnabled() ) {
			log.debug( "inserting: " + key );
		}
		if ( cache instanceof OptimisticCache ) {
			( ( OptimisticCache ) cache ).writeInsert( key, value, currentVersion );
		}
		else {
			cache.update( key, value );
		}
		return true;
	
public SoftLocklock(java.lang.Object key, java.lang.Object version)
Do nothing, returning null.

		//noop
		return null;
	
public booleanput(java.lang.Object key, java.lang.Object value, long txTimestamp, java.lang.Object version, java.util.Comparator versionComparator, boolean minimalPut)

		if ( minimalPut && cache.read( key ) != null ) {
			if ( log.isDebugEnabled() ) {
				log.debug( "item already cached: " + key );
			}
			return false;
		}
		if ( log.isDebugEnabled() ) {
			log.debug( "caching: " + key );
		}
		if ( cache instanceof OptimisticCache ) {
			( ( OptimisticCache ) cache ).writeLoad( key, value, version );
		}
		else {
			cache.put( key, value );
		}
		return true;
	
public voidrelease(java.lang.Object key, SoftLock clientLock)
Do nothing.

		//noop
	
public voidremove(java.lang.Object key)

		if ( log.isDebugEnabled() ) {
			log.debug( "removing: " + key );
		}
		cache.remove( key );
	
public voidsetCache(Cache cache)

		this.cache = cache;
	
public java.lang.StringtoString()

		return cache + "(transactional)";
	
public booleanupdate(java.lang.Object key, java.lang.Object value, java.lang.Object currentVersion, java.lang.Object previousVersion)

		if ( log.isDebugEnabled() ) {
			log.debug( "updating: " + key );
		}
		if ( cache instanceof OptimisticCache ) {
			( ( OptimisticCache ) cache ).writeUpdate( key, value, currentVersion, previousVersion );
		}
		else {
			cache.update( key, value );
		}
		return true;