Class SpringReplayCache
java.lang.Object
org.springframework.ws.soap.security.wss4j2.cache.SpringReplayCache
- All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.wss4j.common.cache.ReplayCache
- Direct Known Subclasses:
ConcurrentMapReplayCache
Apache WSS4J
ReplayCache backed by a Spring Cache. Each key stores an
expiry Instant with configurable TTLs. The default TTL is 5 minutes and the max
TTL is an hour.
contains(String) consults that instant and evicts the entry when it is past expiry.
This does not rely on the backing cache's own TTL configuration.
Subclasses may override onCacheAccess() and to perform additional eviction,
for example, a full sweep over an in-memory cache.
For multi hosts deployment in production, make sure to use a Cache
implementation that is distributed, as each host needs to access the same data. For
simple, single host deployment, ConcurrentMapReplayCache can be used.
- Since:
- 3.1.9
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longDefault TTL for entries in seconds.static final longMaximum TTL for entries in seconds. -
Constructor Summary
ConstructorsConstructorDescriptionSpringReplayCache(org.springframework.cache.Cache cache) Create an instance with the given cache and default TTLs.SpringReplayCache(org.springframework.cache.Cache cache, long defaultTtlSeconds, long maxTtlSeconds) Create an instance with the given cache and TTLs. -
Method Summary
-
Field Details
-
DEFAULT_TTL
public static final long DEFAULT_TTLDefault TTL for entries in seconds.- See Also:
-
MAX_TTL
public static final long MAX_TTLMaximum TTL for entries in seconds.- See Also:
-
-
Constructor Details
-
SpringReplayCache
public SpringReplayCache(org.springframework.cache.Cache cache) Create an instance with the given cache and default TTLs.- Parameters:
cache- the cache to use
-
SpringReplayCache
public SpringReplayCache(org.springframework.cache.Cache cache, long defaultTtlSeconds, long maxTtlSeconds) Create an instance with the given cache and TTLs.- Parameters:
cache- the cache to usedefaultTtlSeconds- the default TTL in secondsmaxTtlSeconds- the maximum TTL in seconds
-
-
Method Details
-
getCache
protected final org.springframework.cache.Cache getCache() -
add
- Specified by:
addin interfaceorg.apache.wss4j.common.cache.ReplayCache
-
add
-
contains
- Specified by:
containsin interfaceorg.apache.wss4j.common.cache.ReplayCache
-
onCacheAccess
protected void onCacheAccess()Invoked when the cache is accessed, either after an entry has been stored or before checking for the presence of one. -
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-