Package com.atlassian.jira.util
Interface CacheMap<K,V>
public interface CacheMap<K,V>
An object that caches values that are mapped under keys.
A CacheMap cannot contain duplicate keys; each key can map to at most one value.
The cache looks a lot like a Map and indeed implementations are likely to use a Map interally as
the data store, however not all operations are implemented or exactly the same so this interface does not extend Map.
- Since:
- v4.0
-
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Removes all of the mappings from this cache.Returns aCollectionview of the values contained in this cache.Returns the value to which the specified key is mapped, ornullif this cache contains no mapping for the key.voidMaps the specified key to the specified value in this cache.voidRemoves the key (and its corresponding value) from this cache.
-
Method Details
-
get
Returns the value to which the specified key is mapped, ornullif this cache contains no mapping for the key.- Parameters:
key- the key.- Returns:
- the value to which the specified key is mapped.
-
put
Maps the specified key to the specified value in this cache.The value can be retrieved by calling the get method with a key that is equal to the original key.
- Parameters:
key- key with which the specified value is to be associatedvalue- value to be associated with the specified key
-
clear
void clear()Removes all of the mappings from this cache. -
remove
Removes the key (and its corresponding value) from this cache. This method does nothing if the key is not in the cache.- Parameters:
key- the key that needs to be removed
-
copyOfValues
Collection<V> copyOfValues()Returns aCollectionview of the values contained in this cache.The collection is a copy of the values that were contained at the time that this operation was called. Concurrent implementations of this interface will likely allow mutating operations to occur while the collection is being constructed, and which of these modifications are in the resulting collection will be timing and implementation dependant.
- Returns:
- a
Collectionview of the values contained in this cache.
-