FileDocCategorySizeDatePackage
OSCache.javaAPI DocHibernate 3.2.52414Thu Apr 21 02:57:20 BST 2005org.hibernate.cache

OSCache

public class OSCache extends Object implements Cache
author
Mathias Bogaert

Fields Summary
private com.opensymphony.oscache.general.GeneralCacheAdministrator
cache
The OSCache 2.0 cache administrator.
private final int
refreshPeriod
private final String
cron
private final String
regionName
Constructors Summary
public OSCache(int refreshPeriod, String cron, String region)

		this.refreshPeriod = refreshPeriod;
		this.cron = cron;
		this.regionName = region;
	
Methods Summary
public voidclear()

		cache.flushAll();
	
public voiddestroy()

		cache.destroy();
	
public java.lang.Objectget(java.lang.Object key)

		try {
			return cache.getFromCache( toString(key), refreshPeriod, cron );
		}
		catch (NeedsRefreshException e) {
			cache.cancelUpdate( toString(key) );
			return null;
		}
	
public longgetElementCountInMemory()

		return -1;
	
public longgetElementCountOnDisk()

		return -1;
	
public java.lang.StringgetRegionName()

		return regionName;
	
public longgetSizeInMemory()

		return -1;
	
public intgetTimeout()

		return Timestamper.ONE_MS * 60000; //ie. 60 seconds
	
public voidlock(java.lang.Object key)

		// local cache, so we use synchronization
	
public longnextTimestamp()

		return Timestamper.next();
	
public voidput(java.lang.Object key, java.lang.Object value)

		cache.putInCache( toString(key), value );
	
public java.lang.Objectread(java.lang.Object key)

		return get(key);
	
public voidremove(java.lang.Object key)

		cache.flushEntry( toString(key) );
	
public voidsetCacheCapacity(int cacheCapacity)

		cache.setCacheCapacity(cacheCapacity);
	
public java.util.MaptoMap()

		throw new UnsupportedOperationException();
	
private java.lang.StringtoString(java.lang.Object key)

	
	    
		return String.valueOf(key) + '." + regionName;
	
public java.lang.StringtoString()

		return "OSCache(" + regionName + ')";
	
public voidunlock(java.lang.Object key)

		// local cache, so we use synchronization
	
public voidupdate(java.lang.Object key, java.lang.Object value)

		put(key, value);