com.octo.android.robospice.persistence.memory
Class LruCacheObjectPersister<T>
java.lang.Object
com.octo.android.robospice.persistence.ObjectPersister<T>
com.octo.android.robospice.persistence.memory.LruCacheObjectPersister<T>
- All Implemented Interfaces:
- CacheCleaner, Persister
- Direct Known Subclasses:
- LruCacheBitmapObjectPersister, LruCacheStringObjectPersister
public class LruCacheObjectPersister<T>
- extends ObjectPersister<T>
Abstract in-memory object persister, based on the Android LRUCache.
- Author:
- David Stemmer, Mike Jancola
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LruCacheObjectPersister
public LruCacheObjectPersister(Class<T> clazz,
LruCache<Object,CacheItem<T>> lruCache)
LruCacheObjectPersister
public LruCacheObjectPersister(ObjectPersister<T> decoratedPersister,
LruCache<Object,CacheItem<T>> lruCache)
getDecoratedPersister
public ObjectPersister<T> getDecoratedPersister()
getLruCache
public LruCache<Object,CacheItem<T>> getLruCache()
loadDataFromCache
public T loadDataFromCache(Object cacheKey,
long maxTimeInCacheBeforeExpiry)
throws CacheLoadingException
- Description copied from class:
ObjectPersister
- Load data from cache if not expired.
- Specified by:
loadDataFromCache
in class ObjectPersister<T>
- Parameters:
cacheKey
- the cacheKey of the data to load.maxTimeInCacheBeforeExpiry
- the maximum time the data can have been stored in cached
before being considered expired. 0 means infinite.
- Returns:
- the data if it could be loaded.
- Throws:
CacheLoadingException
- if the data in cache is expired.
saveDataToCacheAndReturnData
public T saveDataToCacheAndReturnData(T data,
Object cacheKey)
throws CacheSavingException
- Specified by:
saveDataToCacheAndReturnData
in class ObjectPersister<T>
- Throws:
CacheSavingException
isDataInCache
public boolean isDataInCache(Object cacheKey,
long maxTimeInCacheBeforeExpiry)
- Specified by:
isDataInCache
in class ObjectPersister<T>
getCreationDateInCache
public long getCreationDateInCache(Object cacheKey)
throws CacheLoadingException
- Description copied from class:
ObjectPersister
- Return the creation date of creation of cache. entry for a given
cacheKey.
- Specified by:
getCreationDateInCache
in class ObjectPersister<T>
- Parameters:
cacheKey
- the cachekey identifying the object to look for.
- Returns:
- a long corresponding to the creation date of creation of cache.
- Throws:
CacheLoadingException
- if there is no such element in cache.
loadAllDataFromCache
public List<T> loadAllDataFromCache()
throws CacheLoadingException
- Specified by:
loadAllDataFromCache
in class ObjectPersister<T>
- Throws:
CacheLoadingException
getAllCacheKeys
public List<Object> getAllCacheKeys()
- Specified by:
getAllCacheKeys
in class ObjectPersister<T>
removeDataFromCache
public boolean removeDataFromCache(Object cacheKey)
- Specified by:
removeDataFromCache
in class ObjectPersister<T>
removeAllDataFromCache
public void removeAllDataFromCache()
- Specified by:
removeAllDataFromCache
in interface CacheCleaner
- Specified by:
removeAllDataFromCache
in class ObjectPersister<T>
Copyright © 2012-2014. All Rights Reserved.