FileDocCategorySizeDatePackage
ReadOnlyCache.javaAPI DocHibernate 3.2.53154Thu Feb 09 13:48:44 GMT 2006org.hibernate.cache

ReadOnlyCache

public class ReadOnlyCache extends Object implements CacheConcurrencyStrategy
Caches data that is never updated.
see
CacheConcurrencyStrategy

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

	
	  
Methods Summary
public booleanafterInsert(java.lang.Object key, java.lang.Object value, java.lang.Object version)
Do nothing.

		
		if ( log.isDebugEnabled() ) log.debug("Caching after insert: " + key);
		cache.update(key, value);
		return true;
	
public booleanafterUpdate(java.lang.Object key, java.lang.Object value, java.lang.Object version, SoftLock lock)
Unsupported!

		log.error("Application attempted to edit read only item: " + key);
		throw new UnsupportedOperationException("Can't write to a readonly object");
	
public voidclear()

		cache.clear();
	
public voiddestroy()

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

		// noop
	
public synchronized java.lang.Objectget(java.lang.Object key, long timestamp)

		Object result = cache.get(key);
		if ( result!=null && log.isDebugEnabled() ) log.debug("Cache hit: " + key);
		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)
Do nothing.

		return false;
	
public SoftLocklock(java.lang.Object key, java.lang.Object version)
Unsupported!

		log.error("Application attempted to edit read only item: " + key);
		throw new UnsupportedOperationException("Can't write to a readonly object");
	
public synchronized booleanput(java.lang.Object key, java.lang.Object value, long timestamp, java.lang.Object version, java.util.Comparator versionComparator, boolean minimalPut)

		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)
Unsupported!

		log.error("Application attempted to edit read only item: " + key);
		//throw new UnsupportedOperationException("Can't write to a readonly object");
	
public voidremove(java.lang.Object key)

		cache.remove(key);
	
public voidsetCache(Cache cache)

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

		return cache + "(read-only)";
	
public booleanupdate(java.lang.Object key, java.lang.Object value, java.lang.Object currentVersion, java.lang.Object previousVersion)
Unsupported!

		log.error("Application attempted to edit read only item: " + key);
		throw new UnsupportedOperationException("Can't write to a readonly object");