| Constructor and Description |
|---|
CacheSimple(int size) |
| Modifier and Type | Method and Description |
|---|---|
void |
clear() |
boolean |
containsKey(K key)
Does the cache contain the key?
|
V |
getIfPresent(K key)
Get from cache - or return null.
|
V |
getOrFill(K key,
Callable<V> callable)
Get from cache, of not present, call the
Callable
to try to fill the cache. |
boolean |
isEmpty() |
Iterator<K> |
keys()
Iterate over all keys.
|
void |
put(K key,
V thing)
Insert into the cache
|
void |
remove(K key)
Remove from cache - return true if key referenced an entry
|
void |
setDropHandler(BiConsumer<K,V> dropHandler)
Callback for entries when dropped from the cache
|
long |
size()
Current size of cache
|
public boolean containsKey(K key)
CachecontainsKey in interface Cache<K,V>public V getIfPresent(K key)
CachegetIfPresent in interface Cache<K,V>public V getOrFill(K key, Callable<V> callable)
CacheCallable
to try to fill the cache. This operation should be atomic.public void remove(K key)
Cachepublic long size()
Cachepublic Iterator<K> keys()
Cachepublic void setDropHandler(BiConsumer<K,V> dropHandler)
setDropHandler in interface Cache<K,V>Licenced under the Apache License, Version 2.0