Package org.springframework.retry.policy
Class MapRetryContextCache
java.lang.Object
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
FieldsModifier and TypeFieldDescriptionstatic final intDefault value for maximum capacity of the cache. -
Constructor Summary
ConstructorsConstructorDescriptionCreate aMapRetryContextCachewith default capacity.MapRetryContextCache(int defaultCapacity) -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsKey(Object key) voidput(Object key, RetryContext context) voidvoidsetCapacity(int capacity) Public setter for the capacity.
-
Field Details
-
DEFAULT_CAPACITY
public static final int DEFAULT_CAPACITYDefault value for maximum capacity of the cache. This is set to a reasonably low value (4096) to avoid users inadvertently filling the cache with item keys that are inconsistent.- See Also:
-
-
Constructor Details
-
MapRetryContextCache
public MapRetryContextCache()Create aMapRetryContextCachewith default capacity. -
MapRetryContextCache
public MapRetryContextCache(int defaultCapacity) - Parameters:
defaultCapacity- the default capacity
-
-
Method Details
-
setCapacity
public void setCapacity(int capacity) Public setter for the capacity. Prevents 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.- Parameters:
capacity- the capacity to set
-
containsKey
- Specified by:
containsKeyin interfaceRetryContextCache
-
get
- Specified by:
getin interfaceRetryContextCache
-
put
- Specified by:
putin interfaceRetryContextCache
-
remove
- Specified by:
removein interfaceRetryContextCache
-