Class LoadingCacheUtils


  • public final class LoadingCacheUtils
    extends Object
    Guava loading cache utilities.
    Author:
    Martin Kouba
    • Method Detail

      • getCacheValue

        public static <K,​V> V getCacheValue​(com.google.common.cache.LoadingCache<K,​V> cache,
                                                  K key)
        Get the cache value for the given key.
        Type Parameters:
        K - Key type
        V - Value type
        Parameters:
        cache -
        key -
        Returns:
        the cache value
        Throws:
        com.google.common.util.concurrent.ExecutionError - if an error is thrown while loading the value
      • getCastCacheValue

        public static <T,​K,​V> T getCastCacheValue​(com.google.common.cache.LoadingCache<K,​V> cache,
                                                              Object key)
        Get and cast the cache value for the given key.
        Type Parameters:
        T - Required type
        K - Key type
        V - Value type
        Parameters:
        cache -
        key -
        Returns:
        the cache value cast to the required type
        Throws:
        com.google.common.util.concurrent.ExecutionError - if an error is thrown while loading the value