Class EvictableLoadingCache<K,​V>

  • All Implemented Interfaces:
    com.google.common.base.Function<K,​V>, com.google.common.cache.Cache<K,​V>, com.google.common.cache.LoadingCache<K,​V>, Function<K,​V>

    public class EvictableLoadingCache<K,​V>
    extends com.google.common.cache.AbstractLoadingCache<K,​V>
    A LoadingCache implementation similar to ones produced by CacheBuilder.build(CacheLoader), but one that does not exhibit Guava issue #1881: a cache inspection with getIfPresent(Object) or get(Object) is guaranteed to return fresh state after invalidate(Object), invalidateAll(Iterable) or invalidateAll() were called.
    • Method Detail

      • build

        public static <K,​V> com.google.common.cache.LoadingCache<K,​V> build​(OptionalLong expiresAfterWriteMillis,
                                                                                        OptionalLong refreshMillis,
                                                                                        long maximumSize,
                                                                                        boolean recordStats,
                                                                                        com.google.common.cache.CacheLoader<K,​V> cacheLoader)
      • getAll

        public com.google.common.collect.ImmutableMap<K,​V> getAll​(Iterable<? extends K> keys)
                                                                 throws ExecutionException
        Specified by:
        getAll in interface com.google.common.cache.LoadingCache<K,​V>
        Overrides:
        getAll in class com.google.common.cache.AbstractLoadingCache<K,​V>
        Throws:
        ExecutionException
      • getIfPresent

        public V getIfPresent​(Object key)
      • invalidate

        public void invalidate​(Object key)
        Specified by:
        invalidate in interface com.google.common.cache.Cache<K,​V>
        Overrides:
        invalidate in class com.google.common.cache.AbstractCache<K,​V>
      • invalidateAll

        public void invalidateAll​(Iterable<?> keys)
        Specified by:
        invalidateAll in interface com.google.common.cache.Cache<K,​V>
        Overrides:
        invalidateAll in class com.google.common.cache.AbstractCache<K,​V>
      • invalidateAll

        public void invalidateAll()
        Specified by:
        invalidateAll in interface com.google.common.cache.Cache<K,​V>
        Overrides:
        invalidateAll in class com.google.common.cache.AbstractCache<K,​V>
      • size

        public long size()
        Specified by:
        size in interface com.google.common.cache.Cache<K,​V>
        Overrides:
        size in class com.google.common.cache.AbstractCache<K,​V>
      • stats

        public com.google.common.cache.CacheStats stats()
        Specified by:
        stats in interface com.google.common.cache.Cache<K,​V>
        Overrides:
        stats in class com.google.common.cache.AbstractCache<K,​V>
      • asMap

        public ConcurrentMap<K,​V> asMap()
        Specified by:
        asMap in interface com.google.common.cache.Cache<K,​V>
        Specified by:
        asMap in interface com.google.common.cache.LoadingCache<K,​V>
        Overrides:
        asMap in class com.google.common.cache.AbstractCache<K,​V>
      • cleanUp

        public void cleanUp()
        Specified by:
        cleanUp in interface com.google.common.cache.Cache<K,​V>
        Overrides:
        cleanUp in class com.google.common.cache.AbstractCache<K,​V>