iitb.con.caching
Class SimpleLRUCache<K,V>

java.lang.Object
  extended by 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
 
Constructor Summary
SimpleLRUCache()
           
SimpleLRUCache(int maxEntries)
           
 
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
 

Field Detail

MAX_ENTRIES

public int MAX_ENTRIES
Number of entries in the cache

Constructor Detail

SimpleLRUCache

public SimpleLRUCache()

SimpleLRUCache

public SimpleLRUCache(int maxEntries)
Method Detail

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 object
object - cache object
Returns:
true on success