Package org.webharvest
Interface Cache<K,V>
-
- Type Parameters:
K
- type of cache mapping keyV
- type of values stored in cache
- All Known Implementing Classes:
ThreadLocalCache
public interface Cache<K,V>
Cache containing semi-persistent, key-value mappings. Mapping is available in cache until it is manually evicted.Cache
implementations are typically available as singleton instances.- Since:
- 2.1.0-SNAPSHOT
- Version:
- %I%, %G%
- Author:
- Piotr Dyraga
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
contains(K key)
Returns {@link true} ifCache
contains object identified by the given key.void
invalidate(K key)
Discard value cached under the specified key.V
lookup(K key)
Returns value associated with the specified key.void
put(K key, V value)
Associates the specified value with the specified key inCache
.
-
-
-
Method Detail
-
put
void put(K key, V value)
Associates the specified value with the specified key inCache
. IfCache
previously contained a mapping for the specified key, the old value is replaced by the new one.- Parameters:
key
- key under which value will be stored in cachevalue
- value to be stored in cache
-
contains
boolean contains(K key)
Returns {@link true} ifCache
contains object identified by the given key.- Parameters:
key
- key of the object being looked up in theCache
- Returns:
- {@link true} if cache contains object identified by the given key; {@link false} is returned otherwise
-
lookup
V lookup(K key)
Returns value associated with the specified key. If for the given key, no value is currently cached, then {@link null} is returned.- Parameters:
key
- key of the object being looked up in theCache
- Returns:
- object associated with the specified key, or {@link null} if there is no such object
-
invalidate
void invalidate(K key)
Discard value cached under the specified key.- Parameters:
key
- key of the cache binding which is going to be invalidated.
-
-