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

SwarmCache

public class SwarmCache extends Object implements Cache
author
Jason Carreira, Gavin King

Fields Summary
private final net.sf.swarmcache.ObjectCache
cache
private final String
regionName
Constructors Summary
public SwarmCache(net.sf.swarmcache.ObjectCache cache, String regionName)

        this.cache = cache;
        this.regionName = regionName;
    
Methods Summary
public voidclear()
Clear the cache

        cache.clearAll();
    
public voiddestroy()
Clean up

        cache.clearAll();
    
public java.lang.Objectget(java.lang.Object key)
Get an item from the cache

param
key
return
the cached object or null
throws
CacheException

        if (key instanceof Serializable) {
            return cache.get( (Serializable) key );
        } 
        else {
            throw new CacheException("Keys must implement Serializable");
        }
    
public longgetElementCountInMemory()

		return -1;
	
public longgetElementCountOnDisk()

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

		return regionName;
	
public longgetSizeInMemory()

		return -1;
	
public intgetTimeout()
Get a reasonable "lock timeout"

		return 600;
    
public voidlock(java.lang.Object key)
If this is a clustered cache, lock the item

        throw new UnsupportedOperationException("SwarmCache does not support locking (use nonstrict-read-write)");
    
public longnextTimestamp()
Generate a (coarse) timestamp

    	return System.currentTimeMillis() / 100;
    
public voidput(java.lang.Object key, java.lang.Object value)
Add an item to the cache

param
key
param
value
throws
CacheException

        if (key instanceof Serializable) {
            cache.put( (Serializable) key, value );
        } 
        else {
            throw new CacheException("Keys must implement Serializable");
        }
    
public java.lang.Objectread(java.lang.Object key)

		return get(key);
    
public voidremove(java.lang.Object key)
Remove an item from the cache

        if (key instanceof Serializable) {
            cache.clear( (Serializable) key );
        } 
        else {
            throw new CacheException("Keys must implement Serializable");
        }
    
public java.util.MaptoMap()

		throw new UnsupportedOperationException();
	
public java.lang.StringtoString()

		return "SwarmCache(" + regionName + ')";
	
public voidunlock(java.lang.Object key)
If this is a clustered cache, unlock the item

		throw new UnsupportedOperationException("SwarmCache does not support locking (use nonstrict-read-write)");
    
public voidupdate(java.lang.Object key, java.lang.Object value)
Add an item to the cache

param
key
param
value
throws
CacheException

		put(key, value);