| Modifier and Type | Field and Description |
|---|---|
protected CachedValue<V> |
cachedValue |
protected K |
key |
protected Mapper<K,V> |
loader |
protected ReentrantReadWriteLock |
lock |
protected long |
ttlInMs |
| Constructor and Description |
|---|
ConcurrentCacheAtom(K key,
Mapper<K,V> loader,
long ttlInMs) |
| Modifier and Type | Method and Description |
|---|---|
V |
call() |
V |
get()
Returns the cached value, recalculating/reloading it if expired.
|
V |
getIfExists()
Retrieves the cached value if it exists, or
null otherwise. |
void |
invalidate()
Invalidates the cached value.
|
void |
set(V value)
Sets a new cached value.
|
String |
toString() |
protected void |
updateStats(boolean missed,
boolean hasError) |
protected final ReentrantReadWriteLock lock
protected final K key
protected final long ttlInMs
protected volatile CachedValue<V> cachedValue
public V get()
public V getIfExists()
null otherwise.getIfExists in interface CacheAtom<V>protected void updateStats(boolean missed,
boolean hasError)
public void invalidate()
invalidate in interface CacheAtom<V>Copyright © 2014–2018 Nikolche Mihajlovski and contributors. All rights reserved.