Package org.springframework.retry.policy
Class SoftReferenceMapRetryContextCache
java.lang.Object
org.springframework.retry.policy.SoftReferenceMapRetryContextCache
- All Implemented Interfaces:
RetryContextCache
Map-based implementation of
RetryContextCache
. The map backing the cache of
contexts is synchronized and its entries are soft-referenced, so may be garbage
collected under pressure.- Author:
- Dave Syer
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Default value for maximum capacity of the cache. -
Constructor Summary
ConstructorDescriptionCreate aSoftReferenceMapRetryContextCache
with default capacity.SoftReferenceMapRetryContextCache
(int defaultCapacity) -
Method Summary
Modifier and TypeMethodDescriptionboolean
containsKey
(Object key) void
put
(Object key, RetryContext context) void
void
setCapacity
(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
-
SoftReferenceMapRetryContextCache
public SoftReferenceMapRetryContextCache()Create aSoftReferenceMapRetryContextCache
with default capacity. -
SoftReferenceMapRetryContextCache
public SoftReferenceMapRetryContextCache(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:
containsKey
in interfaceRetryContextCache
-
get
- Specified by:
get
in interfaceRetryContextCache
-
put
- Specified by:
put
in interfaceRetryContextCache
-
remove
- Specified by:
remove
in interfaceRetryContextCache
-