E - The type of the cached variablepublic class WeakCache<E> extends Object
WeakReference being null upon accessing| Constructor and Description |
|---|
WeakCache(Supplier<? extends E> update)
Stores the
Supplier for the cached value |
WeakCache(Supplier<? extends E> update,
boolean forceRefresh)
Stores the
Supplier for the cached value |
| Modifier and Type | Method and Description |
|---|---|
void |
forceRefresh()
Forcibly refreshes the current value of this
WeakCache |
E |
get()
Calls a check to see if the cache needs to be updated, and returns the
stored variable
|
protected E |
getCurrentValue()
Returns the currently in-use variable without checking the cache
|
protected void |
setCurrentValue(E value)
Sets the value of this
WeakCache |
public WeakCache(Supplier<? extends E> update)
Supplier for the cached valueupdate - Called when a cached value is nullpublic WeakCache(Supplier<? extends E> update, boolean forceRefresh)
Supplier for the cached valueupdate - Called when a cached value is nullforceRefresh - true to refresh and retrieve the cached
instance upon construction, instead of on the first
call to Cache.get()public final E get()
WeakCacheprotected E getCurrentValue()
WeakCacheprotected void setCurrentValue(E value)
WeakCachevalue - The new value to setpublic final void forceRefresh()
WeakCacheCopyright © 2015. All rights reserved.