|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.github.ignition.support.cache.AbstractCache<String,CachedModel> com.github.ignition.support.cache.ModelCache
public class ModelCache
Allows caching Model objects using the features provided by AbstractCache
. The key into
the cache will be based around the cached object's key, and the object will be able to save and
reload itself from the cache.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface java.util.Map |
---|
Map.Entry<K,V> |
Field Summary |
---|
Fields inherited from class com.github.ignition.support.cache.AbstractCache |
---|
DISK_CACHE_INTERNAL, DISK_CACHE_SDCARD, diskCacheDirectory |
Constructor Summary | |
---|---|
ModelCache(int initialCapacity,
long expirationInMinutes,
int maxConcurrentThreads)
Creates an AbstractCache with params provided and name 'ModelCache'. |
Method Summary | |
---|---|
String |
getFileNameForKey(String url)
Only meaningful if disk caching is enabled. |
CachedModel |
put(String key,
CachedModel value)
Writes an element to the cache. |
protected CachedModel |
readValueFromDisk(File file)
Only meaningful if disk caching is enabled. |
void |
removeAllWithPrefix(String prefix)
Removes all cached objects with key prefix. |
protected void |
writeValueToDisk(File file,
CachedModel data)
Only meaningful if disk caching is enabled. |
Methods inherited from class com.github.ignition.support.cache.AbstractCache |
---|
clear, clear, containsKey, containsKeyInMemory, containsKeyOnDisk, containsValue, enableDiskCache, entrySet, get, getCachedFiles, getDiskCacheDirectory, isDiskCacheEnabled, isEmpty, keySet, putAll, remove, removeKey, setDiskCacheEnabled, size, values |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.Map |
---|
equals, hashCode |
Constructor Detail |
---|
public ModelCache(int initialCapacity, long expirationInMinutes, int maxConcurrentThreads)
AbstractCache
with params provided and name 'ModelCache'.
com.github.droidfu.cachefu.AbstractCache#AbstractCache(java.lang.String, int, long, int)
Method Detail |
---|
public CachedModel put(String key, CachedModel value)
AbstractCache
put
in interface Map<String,CachedModel>
put
in class AbstractCache<String,CachedModel>
com.github.droidfu.cachefu.AbstractCache#put(java.lang.Object, java.lang.Object)
public void removeAllWithPrefix(String prefix)
prefix
- Prefix of all cached object keys to be removedpublic String getFileNameForKey(String url)
AbstractCache
AbstractCache.enableDiskCache(android.content.Context, int)
. Turns a cache key
into the file name that will be used to persist the value to disk. Subclasses must implement
this.
getFileNameForKey
in class AbstractCache<String,CachedModel>
url
- the cache key
com.github.droidfu.cachefu.AbstractCache#getFileNameForKey(java.lang.Object)
protected CachedModel readValueFromDisk(File file) throws IOException
AbstractCache
AbstractCache.enableDiskCache(android.content.Context, int)
. Restores a value
previously persisted to the disk cache.
readValueFromDisk
in class AbstractCache<String,CachedModel>
file
- the file holding the cached value
IOException
com.github.droidfu.cachefu.AbstractCache#readValueFromDisk(java.io.File)
protected void writeValueToDisk(File file, CachedModel data) throws IOException
AbstractCache
AbstractCache.enableDiskCache(android.content.Context, int)
. Persists a value to
the disk cache.
writeValueToDisk
in class AbstractCache<String,CachedModel>
data
- the cache value to persist
IOException
com.github.droidfu.cachefu.AbstractCache#writeValueToDisk(java.io.File,
java.lang.Object)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |