-
- 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 interfaceMemoryCache.CacheTrimStrategyInterface 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 Vinspect(K key)Gets the item with the given key for debug purposes. abstract Unitprobe(K key)Probes whether the object corresponding to the key is in the cache. abstract IntegerremoveAll(Predicate<K> predicate)Removes all the items from the cache whose keys match the specified predicate. abstract Booleancontains(Predicate<K> predicate)Find if any of the items from the cache whose keys match the specified predicate. abstract Booleancontains(K key)Check if the cache contains an item for the given key. abstract IntegergetCount()Gets the total number of all currently cached items. abstract IntegergetSizeInBytes()Gets the total size in bytes of all currently cached items. abstract StringgetDebugData()Return a string describing this object and to be used for debugging or logging -
-
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
-
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
-
-
-
-