public abstract class IntMapLRUCache extends Object
This class is thread-safe.
Constructor and Description |
---|
IntMapLRUCache(int initialSize,
int maxSize)
Create a new LRU cache.
|
IntMapLRUCache(int initialSize,
int maxSize,
int purgeSize)
Create a new LRU cache.
|
Modifier and Type | Method and Description |
---|---|
abstract Object |
fetch(int key) |
int |
firstKey() |
Object |
get(int key)
Retrieve an object from the cache using the specified key.
|
int |
getMaxSize()
Returns the number of elements that this cache can hold.
|
int |
getPurgeSize()
Returns the number of LRU elements to purge when the max size is reached.
|
protected void |
handleLRUElementPurged(int key,
Object value)
Handler hook to signal subclasses that the LRU element has been purged from the cache.
|
Object |
put(int key,
Object value)
Insert an object into the cache.
|
void |
remove(int key)
Remove an object from the cache.
|
void |
setSize(int size) |
int |
size()
Returns the number of elements currently in the cache.
|
public IntMapLRUCache(int initialSize, int maxSize)
initialSize
- the initial size of the IntMapmaxSize
- the maximum number of elements this cache can hold before purging LRU elements.public IntMapLRUCache(int initialSize, int maxSize, int purgeSize)
initialSize
- the initial size of the IntMapmaxSize
- the maximum number of elements this cache can hold before purging LRU elements.purgeSize
- the number of LRU elements to purge once the max size is exceeded.public Object get(int key)
public int firstKey()
public void remove(int key)
public void setSize(int size)
public int size()
public int getMaxSize()
public int getPurgeSize()
protected void handleLRUElementPurged(int key, Object value)
key
- the insertion key that was originally used to add value to the cache.value
- the value element bound to the key.public abstract Object fetch(int key)
Copyright © 2016 The Apache Software Foundation. All rights reserved.