Class CacheUtility
- java.lang.Object
-
- com.broadleafcommerce.common.extension.cache.api.CacheUtility
-
public final class CacheUtility extends Object
Utility class for working with several interactions between broadleaf and spring cache.- Author:
- Jeff Fischer
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ImperativeListChainableforListWith(CacheStateManager cacheStateManager)Fluent API for working withCacheStateManager.computeIfAbsent(Function, ImperativeListCacheInfo).static SingleItemChainableforSingleWith(CacheStateManager cacheStateManager)Fluent API for working withCacheStateManager.computeIfAbsent(Supplier, CacheInfo).static org.springframework.cache.interceptor.SimpleKeygetKey(com.fasterxml.jackson.databind.node.ObjectNode node)Generates aSimpleKeyinstance based on one or more key fragments.static org.springframework.cache.interceptor.SimpleKeygetKey(String prefix, com.fasterxml.jackson.databind.node.ObjectNode node)Generates aSimpleKeyinstance based on one or more key fragments.static Instantnow(TemporalIdentifier temporalIdentifier)Given aTemporalIdentifierinstance, return the current instant in time (either now, or preview)static Instantround(Instant input, TemporalField roundTo, int roundIncrement)Given anInstant, round the instant up to the nearestroundIncrementbased on theroundTotype (e.g.
-
-
-
Method Detail
-
getKey
public static org.springframework.cache.interceptor.SimpleKey getKey(com.fasterxml.jackson.databind.node.ObjectNode node)
Generates aSimpleKeyinstance based on one or more key fragments. Primarily used duringContextKeyGen.generate(Object, Method, Object...)processing, but could also be used for programmaticCacheManagermanipulation.- 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 aSimpleKeyinstance based on one or more key fragments. Primarily used duringContextKeyGen.generate(Object, Method, Object...)processing, but could also be used for programmaticCacheManagermanipulation. This implementation includes a prefix in clear text in the key before the key generated from thenodeparam.- 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
public static Instant round(Instant input, TemporalField roundTo, int roundIncrement)
Given anInstant, round the instant up to the nearestroundIncrementbased on theroundTotype (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
public static Instant now(TemporalIdentifier temporalIdentifier)
Given aTemporalIdentifierinstance, return the current instant in time (either now, or preview)- Parameters:
temporalIdentifier- TheTemporalIdentifierinstance that can generate the target time.- Returns:
- The target time.
-
forListWith
public static ImperativeListChainable forListWith(CacheStateManager cacheStateManager)
Fluent API for working withCacheStateManager.computeIfAbsent(Function, ImperativeListCacheInfo).- Parameters:
cacheStateManager- Supports interaction withCacheManager- Returns:
- The chainable call.
-
forSingleWith
public static SingleItemChainable forSingleWith(CacheStateManager cacheStateManager)
Fluent API for working withCacheStateManager.computeIfAbsent(Supplier, CacheInfo).- Parameters:
cacheStateManager- Supports interaction withCacheManager- Returns:
- The chainable call.
-
-