public abstract class LruMemoryCache<K,V> extends Object implements MemoryCache<K,V>
| Constructor and Description |
|---|
LruMemoryCache(int maxSize) |
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Cleans the cache, by removing all cache entries
|
CacheEntry<V> |
get(K key)
Get the Cached entry
|
void |
onLowMemory()
This method is called, when the memory of the device runs low (RAM).
|
void |
put(K key,
CacheEntry<V> entry)
Put a already existing entry in the memory cache
|
void |
put(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
|
protected int |
sizeOf(K key,
CacheEntry<V> value)
Returns the size of the entry for
key and value in
user-defined units. |
void |
updateExpirationTimestamp(K key,
long expirationTimestamp)
Will be called to update an expiration timestamp.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitisForTypepublic LruMemoryCache(int maxSize)
maxSize - for caches that do not override sizeOf(K, com.hannesdorfmann.httpkit.cache.CacheEntry<V>), this is
the maximum number of entries in the cache. For all other caches,
this is the maximum sum of the sizes of the entries in this cache.public void put(K key, V value, String mimeType, String charsetEncoding, long expirationTimeStamp, String eTag)
CacheEntry to the cache.put in interface MemoryCache<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 i used, to encode the
string content (is useless for binary data)expirationTimeStamp - The expiration valueeTag - The ETagExceptionpublic void put(K key, CacheEntry<V> entry)
MemoryCacheput in interface MemoryCache<K,V>public CacheEntry<V> get(K key)
MemoryCacheget in interface MemoryCache<K,V>public void onLowMemory()
MemoryCacheonLowMemory in interface MemoryCache<K,V>public void clear()
MemoryCacheclear in interface MemoryCache<K,V>protected int sizeOf(K key, CacheEntry<V> value)
key and value in
user-defined units. The default implementation returns 1 so that size
is the number of entries and max size is the maximum number of entries.
An entry's size must not change while it is in the cache.
public void updateExpirationTimestamp(K key, long expirationTimestamp)
SubCacheupdateExpirationTimestamp in interface SubCache<K,V>public void remove(K key) throws IOException
SubCacheremove in interface SubCache<K,V>IOExceptionCopyright © 2015 Hannes Dorfmann. All rights reserved.