Package org.elasticsearch.common.util
Class SingleObjectCache<T>
java.lang.Object
org.elasticsearch.common.util.SingleObjectCache<T>
public abstract class SingleObjectCache<T>
extends java.lang.Object
A very simple single object cache that allows non-blocking refresh calls
triggered by expiry time.
-
Field Summary
Fields Modifier and Type Field Description protected longlastRefreshTimestamp -
Constructor Summary
Constructors Modifier Constructor Description protectedSingleObjectCache(TimeValue refreshInterval, T initialValue) -
Method Summary
Modifier and Type Method Description protected TgetNoRefresh()Return the potentially stale cached entry.TgetOrRefresh()Returns the currently cached object and potentially refreshes the cache before returning.protected booleanneedsRefresh()Returnstrueiff the cache needs to be refreshed.protected abstract Trefresh()Returns a new instance to cache
-
Field Details
-
lastRefreshTimestamp
protected long lastRefreshTimestamp
-
-
Constructor Details
-
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()Returnstrueiff the cache needs to be refreshed.
-