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

NonstrictReadWriteCache

public class NonstrictReadWriteCache extends Object implements 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.
author
Gavin King
see
ReadWriteCache for a much stricter algorithm

Fields Summary
private Cache
cache
private static final Log
log
Constructors Summary
public NonstrictReadWriteCache()


	  
	
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 lock)
Invalidate the item (again, for safety).

		release( key, lock );
		return false;
	
public voidclear()

		if ( log.isDebugEnabled() ) {
			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)
Invalidate the item

		if ( log.isDebugEnabled() ) {
			log.debug( "Invalidating: " + key );
		}

		cache.remove( key );
	
public java.lang.Objectget(java.lang.Object key, long txTimestamp)
Get the most recent version, if available.

		if ( log.isDebugEnabled() ) {
			log.debug( "Cache lookup: " + key );
		}

		Object result = cache.get( key );
		if ( result != null ) {
			log.debug( "Cache hit" );
		}
		else {
			log.debug( "Cache miss" );
		}
		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)
Invalidate the item

		return false;
	
public SoftLocklock(java.lang.Object key, java.lang.Object version)
Do nothing.

return
null, no lock

		return null;
	
public booleanput(java.lang.Object key, java.lang.Object value, long txTimestamp, java.lang.Object version, java.util.Comparator versionComparator, boolean minimalPut)
Add an item to the cache.

		if ( minimalPut && cache.get( key ) != null ) {
			if ( log.isDebugEnabled() ) {
				log.debug( "item already cached: " + key );
			}
			return false;
		}
		if ( log.isDebugEnabled() ) {
			log.debug( "Caching: " + key );
		}

		cache.put( key, value );
		return true;

	
public voidrelease(java.lang.Object key, SoftLock lock)
Invalidate the item (again, for safety).

		if ( log.isDebugEnabled() ) {
			log.debug( "Invalidating (again): " + key );
		}

		cache.remove( key );
	
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 + "(nonstrict-read-write)";
	
public booleanupdate(java.lang.Object key, java.lang.Object value, java.lang.Object currentVersion, java.lang.Object previousVersion)
Do nothing.

		evict( key );
		return false;