Package 

Interface MemoryCache

  • All Implemented Interfaces:
    com.facebook.cache.common.HasDebugData , com.facebook.common.memory.MemoryTrimmable

    
    public interface MemoryCache<K extends Object, V extends Object>
     implements MemoryTrimmable, HasDebugData
                        

    Interface for the image pipeline memory cache.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      public interface MemoryCache.CacheTrimStrategy

      Interface used to specify the trimming strategy for the cache.

    • Method Summary

      Modifier and Type Method Description
      abstract CloseableReference<V> cache(K key, CloseableReference<V> value) Caches the the given key-value pair.
      abstract CloseableReference<V> get(K key) Gets the item with the given key, or null if there is no such item.
      abstract V inspect(K key) Gets the item with the given key for debug purposes.
      abstract Unit probe(K key) Probes whether the object corresponding to the key is in the cache.
      abstract Integer removeAll(Predicate<K> predicate) Removes all the items from the cache whose keys match the specified predicate.
      abstract Boolean contains(Predicate<K> predicate) Find if any of the items from the cache whose keys match the specified predicate.
      abstract Boolean contains(K key) Check if the cache contains an item for the given key.
      abstract Integer getCount() Gets the total number of all currently cached items.
      abstract Integer getSizeInBytes() Gets the total size in bytes of all currently cached items.
      abstract String getDebugData() Return a string describing this object and to be used for debugging or logging
      • Methods inherited from class com.facebook.imagepipeline.cache.MemoryCache

        trim
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • cache

         abstract CloseableReference<V> cache(K key, CloseableReference<V> value)

        Caches the the given key-value pair.

        The cache returns a new copy of the provided reference which should be used instead of the original one. The client should close the returned reference when it is not required anymore.

        If the cache failed to cache the given value, then the null reference is returned.

      • get

         abstract CloseableReference<V> get(K key)

        Gets the item with the given key, or null if there is no such item.

      • inspect

         abstract V inspect(K key)

        Gets the item with the given key for debug purposes. For instance, for LRU caches this will not change the LRU order. Use get(K) instead.

      • probe

         abstract Unit probe(K key)

        Probes whether the object corresponding to the key is in the cache. Note that the act of probing touches the item (if present in cache), thus changing its LRU timestamp.

      • removeAll

         abstract Integer removeAll(Predicate<K> predicate)

        Removes all the items from the cache whose keys match the specified predicate.

        Parameters:
        predicate - returns true if an item with the given key should be removed
      • contains

         abstract Boolean contains(Predicate<K> predicate)

        Find if any of the items from the cache whose keys match the specified predicate.

        Parameters:
        predicate - returns true if an item with the given key matches
      • contains

         abstract Boolean contains(K key)

        Check if the cache contains an item for the given key.

      • getCount

         abstract Integer getCount()

        Gets the total number of all currently cached items.

      • getSizeInBytes

         abstract Integer getSizeInBytes()

        Gets the total size in bytes of all currently cached items.

      • getDebugData

         abstract String getDebugData()

        Return a string describing this object and to be used for debugging or logging