public class ObjectCache<KEY,T> extends Object
| Modifier and Type | Method and Description |
|---|---|
void |
cleanUp()
Removes zombie entries (entries whose reference was set to null).
|
void |
clear()
Clears all cached entries.
|
boolean |
containsKey(KEY key) |
boolean |
containsKeyWithValue(KEY key) |
static <KEY,T> ObjectCache<KEY,T> |
createUsingSoftReferences()
Never use this for external allocations like bitmaps: they are not GCed (tested under Android 2.2)!
|
static <KEY,T> ObjectCache<KEY,T> |
createUsingWeakReferences()
Weak references are a bad cache but the work with external allocations like bitmaps.
|
T |
get(KEY key)
Get the cached entry or null if no valid cached entry is found.
|
boolean |
isValueExpired(KEY key)
Returns true if an entry was found with no value: mainly for testing purposes.
|
Set<KEY> |
keySet() |
T |
put(KEY key,
T object)
Stores an new entry in the cache.
|
void |
putAll(Map<KEY,T> mapDataToPut)
Stores all entries contained in the given map in the cache.
|
T |
remove(KEY key)
Removes an entry from the cache.
|
int |
size() |
public static <KEY,T> ObjectCache<KEY,T> createUsingWeakReferences()
public static <KEY,T> ObjectCache<KEY,T> createUsingSoftReferences()
public void putAll(Map<KEY,T> mapDataToPut)
public void clear()
public void cleanUp()
public boolean isValueExpired(KEY key)
public boolean containsKey(KEY key)
public boolean containsKeyWithValue(KEY key)
public int size()
Copyright © 2014. All rights reserved.