public interface Cache
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Removes all mappings from this map (optional operation).
|
boolean |
containsKey(Object key)
Checks if a given key exists in the cache.
|
Object |
get(Object key)
Returns an object with a given key from the cache.
|
Set |
keySet()
Returns a set view of the keys contained in this cache.
|
void |
put(Object key,
Object value)
Puts an object with a key into the cache.
|
Object |
remove(Object key)
Removes the mapping for this key from this cache if present (optional
operation).
|
int |
size()
Returns the number of elements in this cache (its cardinality).
|
Collection |
values()
Returns a collection view of the values contained in this cache.
|
Object get(Object key)
key - the keyvoid put(Object key, Object value)
key - the keyvalue - the objectboolean containsKey(Object key)
key - the keytrue if the given key exists in the cache, else
falseint size()
Object remove(Object key)
This implementation iterates over entrySet() searching for an entry with the specified key. If such an entry is found, its value is obtained with its getValue operation, the entry is removed from the Collection (and the backing cache) with the iterator's remove operation, and the saved value is returned. If the iteration terminates without finding such an entry, null is returned. Note that this implementation requires linear time in the size of the cache; many implementations will override this method.
key - key whose mapping is to be removed from the cache.void clear()
Set keySet()
Collection values()
Copyright © 2005–2020. All rights reserved.