Class CacheUtility
java.lang.Object
com.broadleafcommerce.common.extension.cache.api.CacheUtility
Utility class for working with several interactions between broadleaf and spring cache.
- Author:
- Jeff Fischer
-
Method Summary
Modifier and TypeMethodDescriptionstatic ImperativeListChainable
forListWith
(CacheStateManager cacheStateManager) Fluent API for working withCacheStateManager.computeIfAbsent(Function, ImperativeListCacheInfo)
.static SingleItemChainable
forSingleWith
(CacheStateManager cacheStateManager) Fluent API for working withCacheStateManager.computeIfAbsent(Supplier, CacheInfo)
.static org.springframework.cache.interceptor.SimpleKey
getKey
(com.fasterxml.jackson.databind.node.ObjectNode node) Generates aSimpleKey
instance based on one or more key fragments.static org.springframework.cache.interceptor.SimpleKey
Generates aSimpleKey
instance based on one or more key fragments.static Instant
now
(TemporalIdentifier temporalIdentifier) Given aTemporalIdentifier
instance, return the current instant in time (either now, or preview)static Instant
round
(Instant input, TemporalField roundTo, int roundIncrement) Given anInstant
, round the instant up to the nearestroundIncrement
based on theroundTo
type (e.g.
-
Method Details
-
getKey
public static org.springframework.cache.interceptor.SimpleKey getKey(com.fasterxml.jackson.databind.node.ObjectNode node) Generates aSimpleKey
instance based on one or more key fragments. Primarily used duringContextKeyGen.generate(Object, Method, Object...)
processing, but could also be used for programmaticCacheManager
manipulation.- Parameters:
node
- The identifying parts that should go into the key definition- Returns:
- The completed key definition for spring cache
-
getKey
public static org.springframework.cache.interceptor.SimpleKey getKey(@Nullable String prefix, com.fasterxml.jackson.databind.node.ObjectNode node) Generates aSimpleKey
instance based on one or more key fragments. Primarily used duringContextKeyGen.generate(Object, Method, Object...)
processing, but could also be used for programmaticCacheManager
manipulation. This implementation includes a prefix in clear text in the key before the key generated from thenode
param.- Parameters:
prefix
- A prefix for the key. Presumably helpful in identifying the cache member in another process.node
- The identifying parts that should go into the key definition- Returns:
- The completed key definition for spring cache
-
round
Given anInstant
, round the instant up to the nearestroundIncrement
based on theroundTo
type (e.g. hour, minute, second, etc...).- Parameters:
input
- The instant in time to roundroundTo
- The aspect of the time to round (e.g. round to the nearest ceiling increment)roundIncrement
- The quantity to use for rounding- Returns:
- The rounded instant in time
-
now
Given aTemporalIdentifier
instance, return the current instant in time (either now, or preview)- Parameters:
temporalIdentifier
- TheTemporalIdentifier
instance that can generate the target time.- Returns:
- The target time.
-
forListWith
Fluent API for working withCacheStateManager.computeIfAbsent(Function, ImperativeListCacheInfo)
.- Parameters:
cacheStateManager
- Supports interaction withCacheManager
- Returns:
- The chainable call.
-
forSingleWith
Fluent API for working withCacheStateManager.computeIfAbsent(Supplier, CacheInfo)
.- Parameters:
cacheStateManager
- Supports interaction withCacheManager
- Returns:
- The chainable call.
-