org.enhydra.jdbc.util
Class LRUCache
java.lang.Object
|
+--org.enhydra.jdbc.util.LRUCache
- Direct Known Subclasses:
- PreparedStatementCache
- public class LRUCache
- extends java.lang.Object
Simple implementation of a cache, using Least Recently Used algorithm
for discarding members when the cache fills up
Constructor Summary |
LRUCache(int maxSize)
Constructor |
Method Summary |
protected void |
cleanupObject(java.lang.Object o)
Override this method to do special cleanup on an object,
such as closing a statement or a connection |
java.lang.Object |
get(java.lang.Object key)
Gets an object from the cache. |
void |
put(java.lang.Object key,
java.lang.Object value)
Puts a new object in the cache. |
java.lang.Object |
remove(java.lang.Object key)
Removes the object from the cache and the lru list |
void |
resize(int newSize)
Resize the cache |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LRUCache
public LRUCache(int maxSize)
- Constructor
put
public void put(java.lang.Object key,
java.lang.Object value)
- Puts a new object in the cache. If the cache is full, it removes
the least recently used object. The new object becomes the most
recently used object.
get
public java.lang.Object get(java.lang.Object key)
- Gets an object from the cache. This object is set to be the
most recenty used
remove
public java.lang.Object remove(java.lang.Object key)
- Removes the object from the cache and the lru list
resize
public void resize(int newSize)
- Resize the cache
cleanupObject
protected void cleanupObject(java.lang.Object o)
- Override this method to do special cleanup on an object,
such as closing a statement or a connection