Class CacheFactory


  • public class CacheFactory
    extends Object
    Author:
    Andrea Di Cesare <andrea@softinstigate.com>
    • Method Detail

      • createLocalLoadingCache

        public static <K,​V> LoadingCache<K,​V> createLocalLoadingCache​(long size,
                                                                                  Cache.EXPIRE_POLICY expirePolicy,
                                                                                  long ttl,
                                                                                  Function<K,​V> loader)
        Type Parameters:
        K - the type of the cache keys
        V - the type of the cached values
        Parameters:
        size - the size of the cache
        expirePolicy - specifies how and when each entry should be automatically removed from the cache
        ttl - Time To Live in milliseconds
        loader - the cache loader used to obtain new values
        Returns:
        the cache
      • createLocalCache

        public static <K,​V> Cache<K,​V> createLocalCache​(long size,
                                                                    Cache.EXPIRE_POLICY expirePolicy,
                                                                    long ttl)
        Type Parameters:
        K - the type of the cache keys
        V - the type of the cached values
        Parameters:
        size - the size of the cache
        expirePolicy - specifies how and when each entry should be automatically removed from the cache
        ttl - Time To Live in milliseconds
        Returns:
        the cache.
      • createLocalCache

        public static <K,​V> Cache<K,​V> createLocalCache​(long size,
                                                                    Cache.EXPIRE_POLICY expirePolicy,
                                                                    long ttl,
                                                                    Consumer<Map.Entry<K,​Optional<V>>> remover)
        Type Parameters:
        K - the type of the cache keys.
        V - the type of the cached values.
        Parameters:
        size - the size of the cache.
        expirePolicy - specifies how and when each entry should be automatically removed from the cache.
        ttl - Time To Live in milliseconds.
        remover - the cache remover to invoke each time a value is automatically removed from the cache according to the expire xpolicy
        Returns:
        the cache.