Class SingleObjectCache<T>


  • public abstract class SingleObjectCache<T>
    extends Object
    A very simple single object cache that allows non-blocking refresh calls triggered by expiry time.
    • Field Detail

      • lastRefreshTimestamp

        protected long lastRefreshTimestamp
    • Constructor Detail

      • SingleObjectCache

        protected SingleObjectCache​(TimeValue refreshInterval,
                                    T initialValue)
    • Method Detail

      • getOrRefresh

        public T getOrRefresh()
        Returns the currently cached object and potentially refreshes the cache before returning.
      • getNoRefresh

        protected final T getNoRefresh()
        Return the potentially stale cached entry.
      • refresh

        protected abstract T refresh()
        Returns a new instance to cache
      • needsRefresh

        protected boolean needsRefresh()
        Returns true iff the cache needs to be refreshed.