| Constructor and Description |
|---|
HybridCache() |
| Modifier and Type | Method and Description |
|---|---|
void |
addDiskCache(DiskCache<K,V> cache)
Add a disk cache
|
void |
addMemoryCache(MemoryCache<K,V> cache)
Adds a memory cache
|
void |
clear()
Cleans the cache, by removing all cache entries
|
CacheEntry<V> |
getFromDiskCache(K key,
Class<?> targetClass,
int collectionType)
Get a value from the cache by passing additional information for the
ParserWriter |
CacheEntry<V> |
getFromMemoryCache(K key)
Do a quick look up.
|
ParserWriterPool |
getParserWriterPool()
Get the
ParserWriterPool. |
void |
onLowMemory()
This method is called, when the memory of the device runs low (RAM).
|
void |
putRawToDiskCache(K key,
byte[] value,
String mimeType,
String charsetEncoding,
Long expirationTimeStamp,
String eTag)
Write as raw bytes
|
void |
putToDiskCache(K key,
V value,
String mimeType,
String charsetEncoding,
Long expirationTimeStamp,
String eTag)
Write
|
void |
putToMemoryCache(K key,
CacheEntry<V> entry)
Put a already existing
CacheEntry to the memory cache. |
void |
putToMemoryCache(K key,
V value,
String mimeType,
String charsetEncoding,
Long expirationTimeStamp,
String eTag)
Adds and create a new
CacheEntry to the cache. |
void |
remove(K key)
Removes the Entry
|
void |
removeDiskCache(DiskCache<K,V> cache)
remove a Disk cache
|
void |
removeMemoryCache(MemoryCache<K,V> cache)
remove a memory cache
|
void |
updateExpirationTimestamp(K key,
long expirationTimestamp)
Updates the cached entries expiration timestamp (identified by the key)
|
public CacheEntry<V> getFromDiskCache(K key, Class<?> targetClass, int collectionType) throws Exception
CacheParserWritergetFromDiskCache in interface Cache<K,V>key - The keytargetClass - The target class, to where the retrieved entry should be
mapped (with an objectmapper)collectionType - The returning collection type, like List, etc. This must be
one of the constatns specified int
ParserWriter.COLLECTION_TYPE_NONE,
ParserWriter.COLLECTION_TYPE_LIST, etc. ...Exceptionpublic void remove(K key) throws IOException
Cacheremove in interface Cache<K,V>IOExceptionpublic ParserWriterPool getParserWriterPool()
CacheParserWriterPool.
Add in there any ParserWriter your cache should be able to handle and parsegetParserWriterPool in interface Cache<K,V>public void onLowMemory()
CacheonLowMemory in interface Cache<K,V>public void clear()
throws IOException
Cacheclear in interface Cache<K,V>IOExceptionpublic CacheEntry<V> getFromMemoryCache(K key)
CachegetFromMemoryCache in interface Cache<K,V>key - The keypublic void addMemoryCache(MemoryCache<K,V> cache)
CacheaddMemoryCache in interface Cache<K,V>public void removeMemoryCache(MemoryCache<K,V> cache)
CacheremoveMemoryCache in interface Cache<K,V>public void addDiskCache(DiskCache<K,V> cache)
CacheaddDiskCache in interface Cache<K,V>public void removeDiskCache(DiskCache<K,V> cache)
CacheremoveDiskCache in interface Cache<K,V>public void putToMemoryCache(K key, V value, String mimeType, String charsetEncoding, Long expirationTimeStamp, String eTag)
CacheCacheEntry to the cache.putToMemoryCache in interface Cache<K,V>key - The keyvalue - The Value for the given keymimeType - The mime type of the value. This is important to find the
correct parser for the stored cache valuecharsetEncoding - The charset like, UTF-8 etc. that is used, to encode the
string content (is useless for binary data)expirationTimeStamp - The expiration valueeTag - The ETagpublic void putToMemoryCache(K key, CacheEntry<V> entry)
CacheCacheEntry to the memory cache.
This will normally be called if you want to put a entry retrieved from disc cache to the memeputToMemoryCache in interface Cache<K,V>public void putToDiskCache(K key, V value, String mimeType, String charsetEncoding, Long expirationTimeStamp, String eTag) throws Exception
CacheputToDiskCache in interface Cache<K,V>Exceptionpublic void putRawToDiskCache(K key, byte[] value, String mimeType, String charsetEncoding, Long expirationTimeStamp, String eTag) throws Exception
CacheputRawToDiskCache in interface Cache<K,V>Exceptionpublic void updateExpirationTimestamp(K key, long expirationTimestamp) throws IOException
CacheupdateExpirationTimestamp in interface Cache<K,V>IOExceptionCopyright © 2015 Hannes Dorfmann. All rights reserved.