Modifier and Type | Class and Description |
---|---|
protected class |
OldLRUCache.Node |
Modifier and Type | Field and Description |
---|---|
protected SoftReferenceCache<K,OldLRUCache.Node> |
cache
SoftReferenceCache which holds actual cached entries.
|
protected OldLRUCache.Node |
head |
protected int |
maxEntries |
protected OldLRUCache.Node |
tail |
Constructor and Description |
---|
OldLRUCache(int maxEntries)
Create a new cache.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clear all entries in the cache.
|
boolean |
containsKey(K key)
True if cache contains a specified key.
|
protected boolean |
deleteLeastRecentlyUsed() |
V |
get(K key)
Retrieve a cached value.
|
int |
getMaxSize()
Returns the maximum number of items allowed in the cache.
|
protected void |
insertNode(OldLRUCache.Node node) |
V |
put(K key,
V value)
Add or replace a cached value.
|
V |
remove(K key)
Remove a specific entry from the cache.
|
protected void |
removeNode(OldLRUCache.Node node) |
int |
size()
Return current size of cache.
|
protected int maxEntries
protected SoftReferenceCache<K,OldLRUCache.Node> cache
protected OldLRUCache.Node head
protected OldLRUCache.Node tail
public OldLRUCache(int maxEntries)
maxEntries
- Maximum number of entries allowed.public void clear()
public boolean containsKey(K key)
containsKey
in interface Cache<K,V>
key
- The key to look up.public int getMaxSize()
public int size()
protected boolean deleteLeastRecentlyUsed()
protected void insertNode(OldLRUCache.Node node)
protected void removeNode(OldLRUCache.Node node)