Class CacheUtils

java.lang.Object
com.atlassian.jira.cache.CacheUtils

public final class CacheUtils extends Object
  • Method Details

    • getBulk

      @Nonnull public static <K, V> Map<K,V> getBulk(@Nonnull com.atlassian.cache.Cache<K,V> cache, @Nonnull Set<K> keys, @Nonnull Function<Set<K>,Map<K,V>> valuesSupplier)
      This method is a slightly changed implementation of ReadThroughCache.getBulk(Set, Function).

      The original implementation uses ReadThroughCache.get(Object) in order to check if value is in cache. When cache instance is initiated with CacheLoader, each ReadThroughCache.get(Object) call for absent in cache value causes value to be loaded using CacheLoader. It makes ReadThroughCache.getBulk(Set, Function) useless.

      The new implementation uses ReadThroughCache.containsKey(Object) to verify if value is in the cache.

      Type Parameters:
      K - key type
      V - value type
      Parameters:
      cache - the cache instance
      keys - set of keys to load
      valuesSupplier - function that loads values
      Returns:
      map with loaded values for keys