org.gcube.contentmanagement.gcubedocumentlibrary.io
Class SimpleLRUCache
java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap<K,V>
java.util.LinkedHashMap<java.lang.String,GCubeDocument>
org.gcube.contentmanagement.gcubedocumentlibrary.io.SimpleLRUCache
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.String,GCubeDocument>, DocumentCache
public class SimpleLRUCache
- extends java.util.LinkedHashMap<java.lang.String,GCubeDocument>
- implements DocumentCache
A LinkedHashMap
-based implementation of DocumentCache
.
- Author:
- Fabio Simeoni (University of Strathclyde)
- See Also:
- Serialized Form
Nested classes/interfaces inherited from class java.util.AbstractMap |
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V> |
Constructor Summary |
SimpleLRUCache()
Creates an instance with default size and load factor value. |
SimpleLRUCache(int size)
Creates an instance with a given size and default load factor value. |
SimpleLRUCache(int s,
float factor)
Creates an instance with a specified initial capacity and load factor. |
Method Summary |
GCubeDocument |
get(java.lang.String id)
Returns a document description from the cache if it exists; |
void |
put(GCubeDocument doc)
Put a document description in the cache. |
Methods inherited from class java.util.LinkedHashMap |
clear, containsValue, get |
Methods inherited from class java.util.HashMap |
clone, containsKey, entrySet, isEmpty, keySet, put, putAll, remove, size, values |
Methods inherited from class java.util.AbstractMap |
equals, hashCode, toString |
Methods inherited from class java.lang.Object |
getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Map |
containsKey, entrySet, equals, hashCode, isEmpty, keySet, put, putAll, remove, size, values |
DEFAULT_SIZE
public static int DEFAULT_SIZE
SimpleLRUCache
public SimpleLRUCache()
- Creates an instance with default size and load factor value.
SimpleLRUCache
public SimpleLRUCache(int size)
- Creates an instance with a given size and default load factor value.
- Parameters:
size
- the initial capacity.
SimpleLRUCache
public SimpleLRUCache(int s,
float factor)
- Creates an instance with a specified initial capacity and load factor.
- Parameters:
size
- the initial capacity.factor
- the load factor.- See Also:
LinkedHashMap.LinkedHashMap(int, float, boolean);
get
public GCubeDocument get(java.lang.String id)
- Returns a document description from the cache if it exists;
- Specified by:
get
in interface DocumentCache
- Parameters:
id
- the identifier of the description.
- Returns:
- the description.
put
public void put(GCubeDocument doc)
- Put a document description in the cache.
- Specified by:
put
in interface DocumentCache
- Parameters:
doc
- the document