Package org.elasticsearch.common.util
Class SingleObjectCache<T>
java.lang.Object
org.elasticsearch.common.util.SingleObjectCache<T>
A very simple single object cache that allows non-blocking refresh calls
triggered by expiry time.
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
SingleObjectCache(org.elasticsearch.core.TimeValue refreshInterval, T initialValue)
-
Method Summary
Modifier and TypeMethodDescriptionprotected T
Return the potentially stale cached entry.Returns the currently cached object and potentially refreshes the cache before returning.protected boolean
Returnstrue
iff the cache needs to be refreshed.protected abstract T
refresh()
Returns a new instance to cache
-
Field Details
-
lastRefreshTimestamp
protected long lastRefreshTimestamp
-
-
Constructor Details
-
SingleObjectCache
-
-
Method Details
-
getOrRefresh
Returns the currently cached object and potentially refreshes the cache before returning. -
getNoRefresh
Return the potentially stale cached entry. -
refresh
Returns a new instance to cache -
needsRefresh
protected boolean needsRefresh()Returnstrue
iff the cache needs to be refreshed.
-