Back to Fresco

InstrumentedMemoryCache

docs/javadoc/reference/com/facebook/imagepipeline/cache/InstrumentedMemoryCache.html

3.6.021.5 KB
Original Source

Fresco

|

|

Packages | Classes

Interfaces

Classes

Packages | Classes

Summary: Ctors | Methods | Inherited Methods | [Expand All]

public class

InstrumentedMemoryCache

extends Object
implements MemoryCache<K, V>

| java.lang.Object | | ↳ | com.facebook.imagepipeline.cache.InstrumentedMemoryCache<K, V> |

Summary

Public Constructors
Public Methods
CloseableReference<V>
Caches the the given key-value pair.
boolean
Check if the cache contains an item for the given key.
boolean
Find if any of the items from the cache whose keys match the specified predicate.
CloseableReference<V>
Gets the item with the given key, or null if there is no such item.
int
Gets the total number of all currently cached items.
String
Return a string describing this object and to be used for debugging or logging
int
Gets the total size in bytes of all currently cached items.
void
Probes whether the object corresponding to the key is in the cache.
int
Removes all the items from the cache whose keys match the specified predicate.
void
Trim memory.

| [Expand] Inherited Methods | | --- | | From class java.lang.Object

| Object | clone() | | boolean | equals(Object arg0) | | void | finalize() | | final Class<?> | getClass() | | int | hashCode() | | final void | notify() | | final void | notifyAll() | | String | toString() | | final void | wait(long arg0, int arg1) | | final void | wait(long arg0) | | final void | wait() |

| | From interface com.facebook.cache.common.HasDebugData

| abstract String | getDebugData() Return a string describing this object and to be used for debugging or logging |

| | From interface com.facebook.common.memory.MemoryTrimmable

| abstract void | trim(MemoryTrimType trimType) Trim memory. |

| | From interface com.facebook.imagepipeline.cache.MemoryCache

| abstract CloseableReference<V> | cache(K key, CloseableReference<V> value) Caches the the given key-value pair. | | abstract boolean | contains(K key) Check if the cache contains an item for the given key. | | 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 | getCount() Gets the total number of all currently cached items. | | abstract int | getSizeInBytes() Gets the total size in bytes of all currently cached items. | | abstract void | probe(K key) Probes whether the object corresponding to the key is in the cache. | | abstract int | removeAll(Predicate<K> predicate) Removes all the items from the cache whose keys match the specified predicate. |

|

Public Constructors

public InstrumentedMemoryCache(MemoryCache<K, V> delegate, MemoryCacheTracker tracker)

Public Methods

public 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 boolean contains(K key)

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

Returns
  • true if the key was found in the cache, false otherwise

public 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 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 int getCount()

Gets the total number of all currently cached items.

public String getDebugData()

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

public int getSizeInBytes()

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

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

public 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

public void trim(MemoryTrimType trimType)

Trim memory.

+Generated by Doclava. +