Class CacheKeyBuilder


  • public class CacheKeyBuilder
    extends Object
    CacheKeyBuilder is a tool for easily generating cache keys of Cacheable objects. The layout of the serialized cache key is like below. +--------------------------------------------------------+ | ID (1 byte) | | type key (1 byte) | serialized value (variable length) | | type key (1 byte) | serialized value (variable length) | | ... | +--------------------------------------------------------+
    • Constructor Detail

      • CacheKeyBuilder

        public CacheKeyBuilder​(byte id)
    • Method Detail

      • appendByteArray

        public CacheKeyBuilder appendByteArray​(byte[] input)
      • appendStrings

        public CacheKeyBuilder appendStrings​(Collection<String> input)
        Add a collection of strings to the cache key. Strings in the collection are concatenated with a separator of '0xFF', and they appear in the cache key in their input order.
        Parameters:
        input - a collection of strings to be included in the cache key
        Returns:
        this instance
      • appendStringsIgnoringOrder

        public CacheKeyBuilder appendStringsIgnoringOrder​(Collection<String> input)
        Add a collection of strings to the cache key. Strings in the collection are sorted by their byte representation and concatenated with a separator of '0xFF'.
        Parameters:
        input - a collection of strings to be included in the cache key
        Returns:
        this instance
      • appendDoubleArray

        public CacheKeyBuilder appendDoubleArray​(double[] input)
      • appendFloatArray

        public CacheKeyBuilder appendFloatArray​(float[] input)
      • appendCacheables

        public CacheKeyBuilder appendCacheables​(Collection<? extends Cacheable> input)
        Add a collection of Cacheables to the cache key. Cacheables in the collection are concatenated without any separator, and they appear in the cache key in their input order.
        Parameters:
        input - a collection of Cacheables to be included in the cache key
        Returns:
        this instance
      • appendCacheablesIgnoringOrder

        public CacheKeyBuilder appendCacheablesIgnoringOrder​(Collection<? extends Cacheable> input)
        Add a collection of Cacheables to the cache key. Cacheables in the collection are sorted by their byte representation and concatenated without any separator.
        Parameters:
        input - a collection of Cacheables to be included in the cache key
        Returns:
        this instance
      • build

        public byte[] build()