Package com.aspectran.core.util.cache
Interface Cache<K,V>
-
- Type Parameters:
K
- the type of keysV
- the type of mapped values
- All Known Implementing Classes:
ConcurrentLruCache
,ConcurrentReferenceCache
public interface Cache<K,V>
A Map-like data structure that stores key-value pairs and provides temporary access to it.- Since:
- 6.6.7
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
clear()
Removes all of the elements from this cache.V
get(K key)
Gets an entry from the cache.boolean
isEmpty()
Returnstrue
if this cache contains no key-value mappings.java.util.Set<K>
keySet()
Returns aSet
view of the keys contained in this cache.void
remove(K key)
Removes the specified element from this cache if it is present.int
size()
Returns the number of elements in this cache.
-
-
-
Method Detail
-
get
V get(K key)
Gets an entry from the cache.- Parameters:
key
- the key whose associated value is to be returned- Returns:
- the element, or
null
, if it does not exist
-
remove
void remove(K key)
Removes the specified element from this cache if it is present.- Parameters:
key
- key with which the specified value is to be associated
-
clear
void clear()
Removes all of the elements from this cache.
-
keySet
java.util.Set<K> keySet()
Returns aSet
view of the keys contained in this cache.- Returns:
- the set view
-
size
int size()
Returns the number of elements in this cache.- Returns:
- the number of elements in this cache
-
isEmpty
boolean isEmpty()
Returnstrue
if this cache contains no key-value mappings.- Returns:
true
if this cache contains no key-value mappings
-
-