Interface ContextKeyGen
-
- All Superinterfaces:
org.springframework.cache.interceptor.KeyGenerator
public interface ContextKeyGen extends org.springframework.cache.interceptor.KeyGenerator
KeyGenerator
to use with Spring Cache for method response caching that needs to take into accountDataRouteContext
as part of the cache key determination. Cache situations that employ repository data from common libraries will be the primary consumer of this pattern when being run with data routing enabled as part of a uber service configuration. For example, caching translation fetch responses would require use of this key generator.- Author:
- Jeff Fischer
-
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default void
applyKeyFromArg(Object param, int position, com.fasterxml.jackson.databind.node.ObjectNode node)
Given a method param filtered as part ofgetArgs(Object...)
, return the key fragment as a String.default Object
generate(Object... params)
default Object
generate(Object target, Method method, Object... params)
default Object
generateWithPrefix(String prefix, Object... params)
default Object[]
getArgs(Object... params)
Give the method call params passed, which params should be used in cache key determination.default String
getRouteKey()
-
-
-
Method Detail
-
generate
default Object generate(@NonNull Object target, @NonNull Method method, @NonNull Object... params)
- Specified by:
generate
in interfaceorg.springframework.cache.interceptor.KeyGenerator
-
generateWithPrefix
default Object generateWithPrefix(@NonNull String prefix, @NonNull Object... params)
-
getRouteKey
default String getRouteKey()
-
getArgs
default Object[] getArgs(Object... params)
Give the method call params passed, which params should be used in cache key determination.- Parameters:
params
- All the params passed to the method call- Returns:
- The filtered list of params that should be considered for this cache key determination
-
applyKeyFromArg
default void applyKeyFromArg(Object param, int position, com.fasterxml.jackson.databind.node.ObjectNode node)
Given a method param filtered as part ofgetArgs(Object...)
, return the key fragment as a String. Implementors have an opportunity to refine the key value here based on the method param. For example, an implementation could return thecontextId
for an entity passed as a param.- Parameters:
param
- The filtered method paramposition
- The position of the parameter in the method signature
-
-