Class PrefixedKeyGenerator

  • All Implemented Interfaces:
    org.springframework.cache.interceptor.KeyGenerator

    public class PrefixedKeyGenerator
    extends Object
    implements org.springframework.cache.interceptor.KeyGenerator

    PrefixedKeyGenerator class.

    This class is responsible for generating cache keys that are specific to a version of the application by prefixing them with git commit hash.

    This allows multiple versions of an application to "share" the same distributed cache even when the structure of the values has changed between those versions of the software.

    This case typically occurs in production to ensure zero-downtime updates across a cluster requiring that two different versions of the application have to run concurrently for some time.

    • Constructor Detail

      • PrefixedKeyGenerator

        public PrefixedKeyGenerator​(org.springframework.boot.info.GitProperties gitProperties,
                                    org.springframework.boot.info.BuildProperties buildProperties)

        Constructor for PrefixedKeyGenerator.

        Parameters:
        gitProperties - a GitProperties object.
        buildProperties - a BuildProperties object.
    • Method Detail

      • generate

        public Object generate​(Object target,
                               Method method,
                               Object... params)
        Specified by:
        generate in interface org.springframework.cache.interceptor.KeyGenerator