com.ibm.commerce.registry
Class LRUDynamicHashtable

java.lang.Object
  |
  +--java.util.Dictionary
        |
        +--java.util.Hashtable
              |
              +--com.ibm.commerce.registry.LRUDynamicHashtable
All Implemented Interfaces:
java.lang.Cloneable, ManagedDynamicCache, java.util.Map, java.io.Serializable

public class LRUDynamicHashtable
extends java.util.Hashtable
implements ManagedDynamicCache

This is the LRUDynamicHashtable class which implements the Least Recently Used (LRU) algorithm to achieve the dynamic caching.

See Also:
Serialized Form

Field Summary
static java.lang.String COPYRIGHT
          IBM copyright notice field.
 
Constructor Summary
LRUDynamicHashtable()
          LRUDynamicHashtable constructor.
LRUDynamicHashtable(int initialCapacity)
          LRUDynamicHashtable constructor.
LRUDynamicHashtable(int initialCapacity, float loadFactor)
          LRUDynamicHashtable constructor.
 
Method Summary
 java.util.Enumeration elements()
          Returns an enumeration of the values in this hashtable.
 java.lang.Object get(java.lang.Object key)
          Returns the value to which the specified key is mapped in this hashtable.
 int getCacheSize()
          Returns the total number of cache entries.
 long getEvictions()
          Returns the number of entries that have been removed from the cache by LRU algorithm.
 long getHits()
          Returns the number of cache hits.
 long getMisses()
          Returns the number of cache misses.
 int getUsedCacheSize()
          Returns the number of currently contained cache entries.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Maps the specified key to the specified value in this hashtable.
 java.lang.Object remove(java.lang.Object key)
          Removes the key and its corresponding value from this hashtable.
 void removeAll()
          Removes all keys from the hashtable.
 void setCacheSize(int size)
          Specifies the cache size.
 void setInitialCapacity(int initialCapacity)
          Initialize the capacity of the registry.
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, entrySet, equals, hashCode, isEmpty, keys, keySet, putAll, rehash, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail
public static final java.lang.String COPYRIGHT
IBM copyright notice field.
See Also:
Constant Field Values
Constructor Detail

LRUDynamicHashtable

public LRUDynamicHashtable()
LRUDynamicHashtable constructor.

LRUDynamicHashtable

public LRUDynamicHashtable(int initialCapacity)
LRUDynamicHashtable constructor.

LRUDynamicHashtable

public LRUDynamicHashtable(int initialCapacity,
                           float loadFactor)
LRUDynamicHashtable constructor.
Method Detail

get

public java.lang.Object get(java.lang.Object key)
Returns the value to which the specified key is mapped in this hashtable.
Specified by:
get in interface java.util.Map
Overrides:
get in class java.util.Hashtable
Parameters:
key - The key used to look up in hashtable.
Returns:
The object associated to the key.

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Maps the specified key to the specified value in this hashtable.
Specified by:
put in interface java.util.Map
Overrides:
put in class java.util.Hashtable
Parameters:
key - The cache key
value - The element associated with the key.
Returns:
The element associated with the key.

setCacheSize

public void setCacheSize(int size)
Specifies the cache size.
Parameters:
size - int

removeAll

public void removeAll()
Removes all keys from the hashtable.

remove

public java.lang.Object remove(java.lang.Object key)
Removes the key and its corresponding value from this hashtable.
Specified by:
remove in interface java.util.Map
Overrides:
remove in class java.util.Hashtable
Parameters:
key - The key in hashtable.
Returns:
The object associated to the key.

elements

public java.util.Enumeration elements()
Returns an enumeration of the values in this hashtable.
Overrides:
elements in class java.util.Hashtable
Returns:
Enumeration of the values in this hashtable.

getMisses

public long getMisses()
Returns the number of cache misses.
Specified by:
getMisses in interface ManagedDynamicCache
Returns:
Number of cache misses.

getEvictions

public long getEvictions()
Returns the number of entries that have been removed from the cache by LRU algorithm.
Specified by:
getEvictions in interface ManagedDynamicCache
Returns:
Number of entries that have been removed from the cache.

getHits

public long getHits()
Returns the number of cache hits.
Specified by:
getHits in interface ManagedDynamicCache
Returns:
Number of cache hits.

getCacheSize

public int getCacheSize()
Returns the total number of cache entries.
Specified by:
getCacheSize in interface ManagedDynamicCache
Returns:
The maximum size of the cahce.

getUsedCacheSize

public int getUsedCacheSize()
Returns the number of currently contained cache entries.
Specified by:
getUsedCacheSize in interface ManagedDynamicCache
Returns:
Number of currently used cache entries.

setInitialCapacity

public void setInitialCapacity(int initialCapacity)
Initialize the capacity of the registry.
Specified by:
setInitialCapacity in interface ManagedDynamicCache