Interface Cache<K,V>
- Type Parameters:
K- The type of the key.V- The type of the value.
- All Known Implementing Classes:
GuavaCache,InMemoryCache,NoCache
public interface Cache<K,V>
-
Method Summary
Modifier and TypeMethodDescriptionbooleanReturnsTrueif the cache contains a entry with the key, orFalseif there is none.Returns the value associated withkeyin this cache, or empty if there is no cached value forkey.booleanisEmpty()ReturnsTrueif the cache is empty, orFalseif there's at least a entry stored in cache.voidAssociates value with key in this cache.voidDiscards any cached value for this key.voidDiscards all entries in the cache.longsize()Returns the number of entries in this cache.
-
Method Details
-
put
Associates value with key in this cache.
If the cache previously contained a value associated with key, the old value is replaced by value.- Parameters:
key- The key to be used as index.value- The value to be stored.
-
get
Returns the value associated withkeyin this cache, or empty if there is no cached value forkey.- Parameters:
key- The key to look for.- Returns:
- The value stored in cache if present.
-
remove
Discards any cached value for this key.- Parameters:
key- The key to be discarded.
-
removeAll
void removeAll()Discards all entries in the cache. -
contains
ReturnsTrueif the cache contains a entry with the key, orFalseif there is none.- Parameters:
key- The key to be verified.- Returns:
Trueif the key is present.
-
size
long size()Returns the number of entries in this cache.- Returns:
- The cache size.
-
isEmpty
boolean isEmpty()ReturnsTrueif the cache is empty, orFalseif there's at least a entry stored in cache.- Returns:
Trueif is empty.
-