-
- All Known Implementing Classes:
LineCache,LruCache,StagedLruCache
public interface Cache<K,V>The base interface for a cache implementation.- Author:
- Philipp Meinen
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_CAPACITYThe default capacity of an object cache.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description intcapacity()voidclear()Remove all elements from the cache.Vget(K key)Query a value from the cache by its key.voidremove(K key)Remove a key-value-pair from the cache.voidset(K key, V value)Sets a key-value-pair to the cache.
-
-
-
Field Detail
-
DEFAULT_CAPACITY
static final int DEFAULT_CAPACITY
The default capacity of an object cache.- See Also:
- Constant Field Values
-
-
Method Detail
-
set
void set(K key, V value)
Sets a key-value-pair to the cache.- Throws:
IllegalArgumentException- if the key isnull.
-
get
V get(K key)
Query a value from the cache by its key.- Returns:
- null if no value for the given key was found. Otherwise the value for this key.
- Throws:
IllegalArgumentException- if the key isnull.
-
remove
void remove(K key)
Remove a key-value-pair from the cache.- Throws:
IllegalArgumentException- if the key isnull.
-
capacity
int capacity()
- Returns:
- the capacity of this cache.
-
clear
void clear()
Remove all elements from the cache.
-
-