public class LruCache<K,E> extends Object
The cache has a maxSize set and when the number of cached
elements exceeds that limit the least recently used element will be removed.
| Constructor and Description |
|---|
LruCache(String name,
int maxSize)
Creates a LRU cache.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear() |
void |
elementCleaned(E element) |
E |
get(K key) |
String |
getName() |
Set<K> |
keySet() |
int |
maxSize()
Returns the maximum size of this cache.
|
void |
put(K key,
E element) |
E |
remove(K key) |
void |
resize(int newMaxSize)
Changes the max size of the cache.
|
int |
size() |
public LruCache(String name, int maxSize)
maxSize < 1 an
IllegalArgumentException is thrown.name - name of cachemaxSize - maximum size of this cachepublic String getName()
public int maxSize()
public void clear()
public int size()
public void resize(int newMaxSize)
newMaxSize is
greater then maxSize() next invoke to maxSize()
will return newMaxSize and the entries in cache will not
be modified.
If newMaxSize is less then size()
the cache will shrink itself removing least recently used element until
size() equals newMaxSize. For each element
removed the elementCleaned(E) method is invoked.
If newMaxSize is less then 1 an
IllegalArgumentException is thrown.
newMaxSize - the new maximum size of the cachepublic void elementCleaned(E element)
Copyright © 2002–2018 The Neo4j Graph Database Project. All rights reserved.