java.lang.Object
org.springframework.retry.policy.AbstractMapRetryContextCache<RetryContext>
org.springframework.retry.policy.MapRetryContextCache
- All Implemented Interfaces:
RetryContextCache
Map-based implementation of
RetryContextCache. The map backing the cache of
contexts is synchronized.- Author:
- Dave Syer
-
Field Summary
Fields inherited from class org.springframework.retry.policy.AbstractMapRetryContextCache
DEFAULT_CAPACITY -
Constructor Summary
ConstructorsConstructorDescriptionCreate an instance withthe default capacityMapRetryContextCache(int capacity) Create an instance with the given capacity, removing the eldest entries when the cache is fullMapRetryContextCache(int capacity, boolean removeEldestEntries) Create an instance with the given capacity and the policy to apply when the cache is full. -
Method Summary
Modifier and TypeMethodDescriptionprotected RetryContextfromValue(RetryContext value) Get theRetryContextfrom the cache value.voidsetCapacity(int capacity) Update the capacity of this cache.protected RetryContexttoValue(RetryContext context) Compute the value to store in the cache.Methods inherited from class org.springframework.retry.policy.AbstractMapRetryContextCache
containsKey, get, getMap, put, remove
-
Constructor Details
-
MapRetryContextCache
public MapRetryContextCache()Create an instance withthe default capacity -
MapRetryContextCache
public MapRetryContextCache(int capacity) Create an instance with the given capacity, removing the eldest entries when the cache is full- Parameters:
capacity- the initial capacity of the cache
-
MapRetryContextCache
public MapRetryContextCache(int capacity, boolean removeEldestEntries) Create an instance with the given capacity and the policy to apply when the cache is full.- Parameters:
capacity- the size of the cacheremoveEldestEntries- whether to remove the eldest entries when the cache is full- Since:
- 1.3.5
-
-
Method Details
-
setCapacity
public void setCapacity(int capacity) Update the capacity of this cache. Prevent the cache from growing unboundedly if items that fail are misidentified and two references to an identical item actually do not have the same key. This can happen when users implement equals and hashCode based on mutable fields, for instance.- Overrides:
setCapacityin classAbstractMapRetryContextCache<RetryContext>- Parameters:
capacity- the capacity to set
-
toValue
Description copied from class:AbstractMapRetryContextCacheCompute the value to store in the cache.- Specified by:
toValuein classAbstractMapRetryContextCache<RetryContext>- Parameters:
context- theRetryContextto store- Returns:
- the cache value
-
fromValue
Description copied from class:AbstractMapRetryContextCacheGet theRetryContextfrom the cache value.- Specified by:
fromValuein classAbstractMapRetryContextCache<RetryContext>- Parameters:
value- the cache value- Returns:
- the retry context
-