Class LRUCache<K,V>
java.lang.Object
com.amazonaws.secretsmanager.caching.cache.LRUCache<K,V>
An LRU cache based on the Java LinkedHashMap.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clear the cache.booleancontainsKey(K key) Determine if the cache contains the given key.Return the value mapped to the given key.Return the previously mapped value and map a new value.getAndRemove(K key) Return the previously mapped value and remove the key.voidMap a given key to the given value.voidCopies all of the mappings from the provided map to this cache.booleanputIfAbsent(K key, V value) Map a given key to the given value if not already mapped.booleanRemove a given key from the cache.booleanRemove a given key and value from the cache.voidRemove all of the cached items.
-
Constructor Details
-
LRUCache
public LRUCache()Construct a new cache with default settings. -
LRUCache
public LRUCache(int maxSize) Construct a new cache based on the given max size.- Parameters:
maxSize- The maximum number of items to store in the cache.
-
-
Method Details
-
get
Return the value mapped to the given key.- Parameters:
key- The key used to return the mapped value.- Returns:
- The value mapped to the given key.
-
containsKey
Determine if the cache contains the given key.- Parameters:
key- The key used to determine it there is a mapped value.- Returns:
- True if a value is mapped to the given key.
-
put
Map a given key to the given value.- Parameters:
key- The key to map to the given value.value- The value to map to the given key.
-
getAndPut
Return the previously mapped value and map a new value.- Parameters:
key- The key to map to the given value.value- The value to map to the given key.- Returns:
- The previously mapped value to the given key.
-
putAll
Copies all of the mappings from the provided map to this cache. These mappings will replace any keys currently in the cache.- Parameters:
map- The mappings to copy.
-
putIfAbsent
Map a given key to the given value if not already mapped.- Parameters:
key- The key to map to the given value.value- The value to map to the given key.- Returns:
- True if the mapping has been made.
-
remove
Remove a given key from the cache.- Parameters:
key- The key to remove.- Returns:
- True if the key has been removed.
-
remove
Remove a given key and value from the cache.- Parameters:
key- The key to remove.oldValue- The value to remove.- Returns:
- True if the key and oldValue has been removed.
-
getAndRemove
Return the previously mapped value and remove the key.- Parameters:
key- The key to remove.- Returns:
- The previously mapped value to the given key.
-
removeAll
public void removeAll()Remove all of the cached items. -
clear
public void clear()Clear the cache.
-