public interface

MemoryCache

com.facebook.imagepipeline.cache.MemoryCache<K, V>
Known Indirect Subclasses

Class Overview

Interface for the image pipeline memory cache.

Summary

Public Methods
abstract CloseableReference<V> cache(K key, CloseableReference<V> value)
Caches the the given key-value pair.
abstract boolean contains(Predicate<K> predicate)
Find if any of the items from the cache whose keys match the specified predicate.
abstract CloseableReference<V> get(K key)
Gets the item with the given key, or null if there is no such item.
abstract int removeAll(Predicate<K> predicate)
Removes all the items from the cache whose keys match the specified predicate.

Public Methods

public 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.

Returns
  • a new reference to be used, or null if the caching failed

public 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
Returns
  • true if the predicate was found in the cache, false otherwise

public abstract CloseableReference<V> get (K key)

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

Returns
  • a reference to the cached value, or null if the item was not found

public abstract int 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
Returns
  • number of the items removed from the cache