Package io.wcm.caravan.pipeline.cache
Class CachePersistencyOptions
- java.lang.Object
-
- io.wcm.caravan.pipeline.cache.CachePersistencyOptions
-
@ProviderType public final class CachePersistencyOptions extends Object
Cache persistency options configure entry store requirements while read or write operations inCacheAdapter
. Options specify cache response refresh interval, storage time and automatical extension of storage time per stored entry. See alsoCacheStrategy
.
-
-
Constructor Summary
Constructors Constructor Description CachePersistencyOptions(int refreshInterval, int storageTime, boolean extendStorageTimeOnGet)
Default constructor for complete initialization of cache persistency and transient options.CachePersistencyOptions(int refreshInterval, int storageTime, boolean extendStorageTimeOnGet, boolean shouldUseTransientCaches)
Default constructor for complete initialization of cache persistency and transient options.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static CachePersistencyOptions
createPersistentAndTimeToIdle(int refreshInterval, int storageTime)
Creates caching options specifying cache refresh interval and storing time per entry with next extension of storing time.static CachePersistencyOptions
createPersistentAndTimeToLive(int refreshInterval, int storageTime)
Creates caching options specifying cache refresh interval and storing time per entry without next extension of storing time.static CachePersistencyOptions
createTransient(int refreshInterval)
Creates caching options specifying cache refresh interval.int
getRefreshInterval()
Defines the time (in seconds) after which a cached response for the given request should be considered stale.int
getStorageTime()
Defines the time (in seconds) for which the response to the given request should be at least stored in the cache.boolean
isCacheable()
Checks if the entry should be cached.boolean
isExtendStorageTimeOnGet()
Determines whether to automatically extend the storage time (to the duration returned bygetStorageTime()
whenever a response was successfully retrieved from cache, resulting in a "time-to-idle" cache behavior, where the total storage time is unlimited, but instead data is kept in the cache as long as it is still being requested.boolean
isPersistent()
Deprecated.UseshouldUsePersistentCaches()
instead of deprecatedisPersistent()
.boolean
shouldUsePersistentCaches()
Check if the entry should be cached by persistent cache implementation.boolean
shouldUseTransientCaches()
Check if the entry should be cached by transient cache implementation.String
toString()
-
-
-
Constructor Detail
-
CachePersistencyOptions
public CachePersistencyOptions(int refreshInterval, int storageTime, boolean extendStorageTimeOnGet)
Default constructor for complete initialization of cache persistency and transient options.- Parameters:
refreshInterval
- cached response refresh interval in secondsstorageTime
- time of response storing in secondsextendStorageTimeOnGet
- true if storage time should be extended
-
CachePersistencyOptions
public CachePersistencyOptions(int refreshInterval, int storageTime, boolean extendStorageTimeOnGet, boolean shouldUseTransientCaches)
Default constructor for complete initialization of cache persistency and transient options.- Parameters:
refreshInterval
- cached response refresh interval in secondsstorageTime
- time of response storing in secondsextendStorageTimeOnGet
- true if storage time should be extendedshouldUseTransientCaches
- true if transient cache adapters should be enabled, false if disabled
-
-
Method Detail
-
createPersistentAndTimeToLive
public static CachePersistencyOptions createPersistentAndTimeToLive(int refreshInterval, int storageTime)
Creates caching options specifying cache refresh interval and storing time per entry without next extension of storing time.- Parameters:
refreshInterval
- cached response refresh interval in secondsstorageTime
- time of response storing in seconds- Returns:
- persistent and transient caching options without storage time extension
-
createPersistentAndTimeToIdle
public static CachePersistencyOptions createPersistentAndTimeToIdle(int refreshInterval, int storageTime)
Creates caching options specifying cache refresh interval and storing time per entry with next extension of storing time.- Parameters:
refreshInterval
- cached response refresh interval in secondsstorageTime
- time of response storing in seconds- Returns:
- persistent and transient caching options with storage time extension
-
createTransient
public static CachePersistencyOptions createTransient(int refreshInterval)
Creates caching options specifying cache refresh interval. No entry storing time is declared.- Parameters:
refreshInterval
- cached response refresh interval in seconds- Returns:
- transient caching options
-
getRefreshInterval
public int getRefreshInterval()
Defines the time (in seconds) after which a cached response for the given request should be considered stale. After this time, theJsonPipeline
will try to fetch a fresh response from the origin server, and will only use the stale content from cache as a fallback if this attempt fails.- Returns:
- the duration in seconds until a cached response is considered stale, and should be re-validated
-
getStorageTime
public int getStorageTime()
Defines the time (in seconds) for which the response to the given request should be at least stored in the cache. The actual storage time can be longer ifisExtendStorageTimeOnGet()
or for other technical reasons.- Returns:
- the minimum duration in seconds to keep the response in the cache
-
isExtendStorageTimeOnGet
public boolean isExtendStorageTimeOnGet()
Determines whether to automatically extend the storage time (to the duration returned bygetStorageTime()
whenever a response was successfully retrieved from cache, resulting in a "time-to-idle" cache behavior, where the total storage time is unlimited, but instead data is kept in the cache as long as it is still being requested.- Returns:
- true if the storage value for this request should be extended on every cache hit
-
isCacheable
public boolean isCacheable()
Checks if the entry should be cached.- Returns:
- true if refresh interval is specified (more than 0).
-
isPersistent
@Deprecated public boolean isPersistent()
Deprecated.UseshouldUsePersistentCaches()
instead of deprecatedisPersistent()
.Check if theentry should be cached by persistent cache implementation. A configuration to enable or disable cache operations by persistent adapters.- Returns:
- true if persistent adapters should be supported (storage time is specified, more than 0).
-
shouldUsePersistentCaches
public boolean shouldUsePersistentCaches()
Check if the entry should be cached by persistent cache implementation. A configuration to enable or disable cache operations by persistent adapters.- Returns:
- true if persistent adapters should be supported (storage time is specified, more than 0).
-
shouldUseTransientCaches
public boolean shouldUseTransientCaches()
Check if the entry should be cached by transient cache implementation. A configuration to enable or disable cache operations by transient adapters.- Returns:
- true if transient adapter should be supported
-
-