public interface InterfaceLruCache<K,V>
Modifier and Type | Method and Description |
---|---|
void |
clear()
Removes all entries from cache
|
boolean |
contains(K key)
Checks whether cache contains valid entry for key
|
int |
forceClearOldest()
Removes all oldest entries from cache (ttl based)
|
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.
|
int |
getCapacity()
Returns cache capacity
|
long |
getTtl()
Returns cache TTL
|
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
|
V |
remove(K key)
Removes entry from cache (if exists)
|
void |
setNewTtl(long ttl)
Set a new TTL (for newly set objects only, not changing old values).
|
int |
size()
Returns number of entries stored in cache (including invalid ones)
|
void |
updateTtl(K key)
Update the TTL of the associated object if it still exists
|
void clear()
int forceClearOldest()
boolean contains(K key)
key
- V get(K key)
key
- V get(K key, Callable<V> callback) throws Exception
Default TTL is used
key
- callback
- Exception
- if callback throws exceptionV get(K key, Callable<V> callback, long ttl) throws Exception
key
- callback
- ttl
- time to live in millisecondsException
- if callback throws exceptionint getCapacity()
int size()
long getTtl()
void setNewTtl(long ttl)
ttl
- boolean isEmpty()
If any entry exists (including invalid one) this method will return true
void put(K key, V value)
key
- value
- void put(K key, V value, long ttl)
key
- value
- ttl
- time to live in millisecondsV remove(K key)
key
- void updateTtl(K key)
key
- Copyright © 2009–2020 Waarp. All rights reserved.