public class BasicLruCache<K,V> extends Object
android.util.LruCache where that is available.| Constructor and Description |
|---|
BasicLruCache(int maxSize) |
| Modifier and Type | Method and Description |
|---|---|
protected V |
create(K key)
Called after a cache miss to compute a value for the corresponding key.
|
protected void |
entryEvicted(K key,
V value)
Called for entries that have reached the tail of the least recently used
queue and are be removed.
|
void |
evictAll()
Clear the cache, calling
entryEvicted(K, V) on each removed entry. |
V |
get(K key)
Returns the value for
key if it exists in the cache or can be
created by #create. |
V |
put(K key,
V value)
Caches
value for key. |
Map<K,V> |
snapshot()
Returns a copy of the current contents of the cache, ordered from least
recently accessed to most recently accessed.
|
public final V get(K key)
key if it exists in the cache or can be
created by #create. If a value was returned, it is moved to the
head of the queue. This returns null if a value is not cached and cannot
be created.public final V put(K key, V value)
value for key. The value is moved to the head of
the queue.key. Although that entry is
no longer cached, it has not been passed to entryEvicted(K, V).protected void entryEvicted(K key, V value)
protected V create(K key)
public final Map<K,V> snapshot()
public final void evictAll()
entryEvicted(K, V) on each removed entry.