Package com.aspectran.utils.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
Modifier and TypeMethodDescriptionvoid
clear()
Removes all of the elements from this cache.Gets an entry from the cache.boolean
isEmpty()
Returnstrue
if this cache contains no key-value mappings.keySet()
Returns aSet
view of the keys contained in this cache.void
Removes the specified element from this cache if it is present.int
size()
Returns the number of elements in this cache.
-
Method Details
-
get
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
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
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
-