FileDocCategorySizeDatePackage
SimpleMRUCache.javaAPI DocHibernate 3.2.51409Wed Feb 15 09:35:34 GMT 2006org.hibernate.util

SimpleMRUCache

public class SimpleMRUCache extends Object implements Serializable
Cache following a "Most Recently Used" (MRU) algorithm for maintaining a bounded in-memory size; the "Least Recently Used" (LRU) entry is the first available for removal from the cache.

This implementation uses a bounded MRU Map to limit the in-memory size of the cache. Thus the size of this cache never grows beyond the stated size.

author
Steve Ebersole

Fields Summary
public static final int
DEFAULT_STRONG_REF_COUNT
private final int
strongReferenceCount
private transient org.apache.commons.collections.LRUMap
cache
Constructors Summary
public SimpleMRUCache()


	  
		this( DEFAULT_STRONG_REF_COUNT );
	
public SimpleMRUCache(int strongReferenceCount)

		this.strongReferenceCount = strongReferenceCount;
		init();
	
Methods Summary
public synchronized voidclear()

		cache.clear();
	
public synchronized java.lang.Objectget(java.lang.Object key)

		return cache.get( key );
	
private voidinit()

		cache = new LRUMap( strongReferenceCount );
	
public synchronized java.lang.Objectput(java.lang.Object key, java.lang.Object value)

		return cache.put( key, value );
	
private voidreadObject(java.io.ObjectInputStream in)

		in.defaultReadObject();
		init();
	
public synchronized intsize()

		return cache.size();