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 account DataRouteContext 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 Details

    • generate

      default Object generate(@NonNull Object target, @NonNull Method method, @NonNull Object... params)
      Specified by:
      generate in interface org.springframework.cache.interceptor.KeyGenerator
    • generate

      default Object generate(@NonNull Object... params)
    • 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 of getArgs(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 the contextId for an entity passed as a param.
      Parameters:
      param - The filtered method param
      position - The position of the parameter in the method signature