
public abstract class AbstractLruCache<K,V> extends Object implements InterfaceLruCache<K,V>
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractLruCache(long ttl)
Constructs BaseLruCache
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(K key)
Checks whether cache contains valid entry for key
|
protected InterfaceLruCacheEntry<V> |
createEntry(V value,
long ttl)
Creates new LruCacheEntry
|
V |
get(K key)
Returns value cached with key.
|
V |
get(K key,
Callable<V> callback)
Tries to get element from cache.
|
V |
get(K key,
Callable<V> callback,
long ttl)
Tries to get element from cache.
|
protected abstract InterfaceLruCacheEntry<V> |
getEntry(K key)
Returns LruCacheEntry mapped by key or null if it does not exist
|
long |
getTtl()
Returns cache TTL
|
protected V |
getValue(K key)
Tries to retrieve value by it's key.
|
boolean |
isEmpty()
Checks whether cache is empty.
|
void |
put(K key,
V value)
Puts value under key into cache.
|
void |
put(K key,
V value,
long ttl)
Puts value under key into cache with desired TTL
|
protected abstract void |
putEntry(K key,
InterfaceLruCacheEntry<V> entry)
Puts entry into cache
|
void |
setNewTtl(long ttl)
Set a new TTL (for newly set objects only, not changing old values).
|
void |
updateTtl(K key)
Update the TTL of the associated object if it still exists
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitclear, forceClearOldest, getCapacity, remove, sizeprotected AbstractLruCache(long ttl)
ttl - IllegalArgumentException - if ttl is not positivepublic boolean contains(K key)
InterfaceLruCachecontains in interface InterfaceLruCache<K,V>protected InterfaceLruCacheEntry<V> createEntry(V value, long ttl)
value - ttl - public V get(K key)
InterfaceLruCacheget in interface InterfaceLruCache<K,V>public V get(K key, Callable<V> callback) throws Exception
InterfaceLruCacheget in interface InterfaceLruCache<K,V>Exception - if callback throws exceptionpublic V get(K key, Callable<V> callback, long ttl) throws Exception
InterfaceLruCacheget in interface InterfaceLruCache<K,V>ttl - time to live in millisecondsException - if callback throws exceptionpublic long getTtl()
InterfaceLruCachegetTtl in interface InterfaceLruCache<K,V>public void setNewTtl(long ttl)
InterfaceLruCachesetNewTtl in interface InterfaceLruCache<K,V>protected abstract InterfaceLruCacheEntry<V> getEntry(K key)
key - public void updateTtl(K key)
InterfaceLruCacheupdateTtl in interface InterfaceLruCache<K,V>protected V getValue(K key)
key - public boolean isEmpty()
InterfaceLruCacheisEmpty in interface InterfaceLruCache<K,V>public void put(K key, V value)
InterfaceLruCacheput in interface InterfaceLruCache<K,V>public void put(K key, V value, long ttl)
InterfaceLruCacheput in interface InterfaceLruCache<K,V>ttl - time to live in millisecondsprotected abstract void putEntry(K key, InterfaceLruCacheEntry<V> entry)
key - entry - Copyright © 2009–2019 Waarp. All rights reserved.