iitb.con.caching
Class SimpleLRUCache<K,V>
java.lang.Object
iitb.con.caching.SimpleLRUCache<K,V>
public class SimpleLRUCache<K,V>
- extends java.lang.Object
A simple LRU cache. It does not implement the cache interface, which specifically
uses CacheObject
for cache object. This class allows to use any type as
cache object.
Field Summary |
int |
MAX_ENTRIES
Number of entries in the cache |
Method Summary |
V |
get(K key)
Returns the cached object for the given key |
V |
put(K key,
V object)
Places the cache object in the cache using the key |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MAX_ENTRIES
public int MAX_ENTRIES
- Number of entries in the cache
SimpleLRUCache
public SimpleLRUCache()
SimpleLRUCache
public SimpleLRUCache(int maxEntries)
get
public V get(K key)
- Returns the cached object for the given key
- Parameters:
key
- key used to retrieve the object
- Returns:
- cached object if present, else returns NULL
put
public V put(K key,
V object)
- Places the cache object in the cache using the key
- Parameters:
key
- key used to place the objectobject
- cache object
- Returns:
- true on success