net.sf.jso.cache
Class LRUCache

java.lang.Object
  extended bynet.sf.jso.cache.LRUCache
All Implemented Interfaces:
Cache, CacheInfo

public class LRUCache
extends java.lang.Object
implements Cache, CacheInfo


Constructor Summary
LRUCache(int sz)
           
 
Method Summary
 long accesses()
          Informs how many times the cache has been accessed through Cache.get() method.
 java.lang.String algorithm()
          Informs the algorithm used by the cache for entry management.
 java.lang.String description()
          Informs a description of the entry management algorithm.
 java.lang.Object get(java.lang.Object key)
          Gets an object in the cache.
 CacheInfo getCacheInfo()
          Gets cache information.
 long hits()
          Informs how many times the cache could return a valid object associated with a key through Cache.get() method.
 int inUse()
          Informs the cache usage.
 void invalidate()
          Invalidates all cached objects.
 long misses()
          Informs how many times the cache could not find any object associated with a key through Cache.get() method.
 java.lang.Object put(java.lang.Object key, java.lang.Object obj)
          Puts an object in the cache.
 int size()
          Informs the cache size.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LRUCache

public LRUCache(int sz)
Method Detail

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object obj)
Description copied from interface: Cache
Puts an object in the cache.

Specified by:
put in interface Cache
Parameters:
key - A key with which the specified object is to be associated.
obj - An object to be associated with the specified key.

get

public java.lang.Object get(java.lang.Object key)
Description copied from interface: Cache
Gets an object in the cache.

Specified by:
get in interface Cache
Parameters:
key - The key to which the object is associated.
Returns:
If an object associated with the supplied key is found this object is returned. Otherwise null is returned.

invalidate

public void invalidate()
Description copied from interface: Cache
Invalidates all cached objects.

Specified by:
invalidate in interface Cache

getCacheInfo

public CacheInfo getCacheInfo()
Description copied from interface: Cache
Gets cache information.

Specified by:
getCacheInfo in interface Cache
Returns:
Information about the cache.

accesses

public long accesses()
Description copied from interface: CacheInfo
Informs how many times the cache has been accessed through Cache.get() method.

Specified by:
accesses in interface CacheInfo
Returns:
The total number of accesses.

hits

public long hits()
Description copied from interface: CacheInfo
Informs how many times the cache could return a valid object associated with a key through Cache.get() method.

Specified by:
hits in interface CacheInfo
Returns:
The number of times the cache returned valid objects.

misses

public long misses()
Description copied from interface: CacheInfo
Informs how many times the cache could not find any object associated with a key through Cache.get() method.

Specified by:
misses in interface CacheInfo
Returns:
The number of times the cache did not return valid objects.

size

public int size()
Description copied from interface: CacheInfo
Informs the cache size.

Specified by:
size in interface CacheInfo
Returns:
The number of entries the cache is able to manage.

inUse

public int inUse()
Description copied from interface: CacheInfo
Informs the cache usage.

Specified by:
inUse in interface CacheInfo
Returns:
The number of entries are in use by the cache.

algorithm

public java.lang.String algorithm()
Description copied from interface: CacheInfo
Informs the algorithm used by the cache for entry management.

Specified by:
algorithm in interface CacheInfo
Returns:
The name (acronym) of the algorithm.

description

public java.lang.String description()
Description copied from interface: CacheInfo
Informs a description of the entry management algorithm.

Specified by:
description in interface CacheInfo
Returns:
A description (complete name, functional description) of the algorithm.