|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjdbm.helper.LRUCache<K,V>
public class LRUCache<K,V>
This class implements a versioned lru cache. Entries in the cache are identified with a key. When clients get a reference to the an entry, they point to the same object. Hence when the client wants to update and put a new version of the entry to the cache, he should not modify the object it got through the get interface (might copy on write). As new versions of the entries are put, cache maintains the previous versions of the entry. CLients specify the version of the cache entry they want to read. Clients are supposed to update the minimum read version the clients might request so that cache can purge older versions of data. For now, this class assumes clients make sure that put operations are serialized.
| Constructor Summary | |
|---|---|
LRUCache(EntryIO<K,V> entryIO,
int cacheSize)
|
|
| Method Summary | |
|---|---|
void |
advanceMinReadVersion(long minVersion)
Called as the minimum version that readers will use advances. |
V |
get(K key,
long version,
Serializer serializer)
Finds and returns the entry corresponding to the given key and version. |
void |
put(K key,
V value,
long newVersion,
Serializer serializer,
boolean neverReplace)
Updates the entry identified with the key with the new value. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public LRUCache(EntryIO<K,V> entryIO,
int cacheSize)
| Method Detail |
|---|
public void advanceMinReadVersion(long minVersion)
minVersion - mimimum version that will be read from the cache
public void put(K key,
V value,
long newVersion,
Serializer serializer,
boolean neverReplace)
throws IOException,
CacheEvictionException
key - identifier of the entryvalue - new value of the entrynewVersion - version of the new valueserializer - used in case of IOneverReplace - true if caller wants to always keep the entry in cache
IOException, - CacheEvictionException
IOException
CacheEvictionException
public V get(K key,
long version,
Serializer serializer)
throws IOException
key - the identifier for the entryversion - version the caller want to readserializer - used in case of IO
IOExceptionpublic String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||