E
- the type of values being cachedpublic class InlineCache<E> extends Object
Caches a computed value for a certain amount of time. Re-computes the value once the value is expired and the cache is used again.
A real lookup cache, with a Map like behaviour can be found here: Cache
.
Use CacheManager.createInlineCache(java.time.Duration, java.util.function.Supplier)
to create a new inline cache.
Modifier | Constructor and Description |
---|---|
protected |
InlineCache(Supplier<E> computer,
long timeout)
Creates a new inline cache based on the given parameters.
|
Modifier and Type | Method and Description |
---|---|
void |
flush()
Forces the cache to reset and re-compute its internal value on the next access
|
E |
get()
Either returns a cached value or computes a new one, if no valid value is in the cache.
|
@Nullable public E get()
public void flush()
Copyright © 2018. All rights reserved.