Class RefreshAheadCache

  • All Implemented Interfaces:
    java.lang.Cloneable, Ehcache, InternalEhcache

    public class RefreshAheadCache
    extends EhcacheDecoratorAdapter
    A cache decorator which implements read ahead refreshing. Read ahead occurs when a cache entry is accessed prior to its expiration, and triggers a reload of the value in the background.

    A significant attempt is made to ensure only one node of the cache works on a specific key at a time. There is no guarantee that every triggered refresh ahead case will be processed. As the maximum number of backlog entries is reached, refresh ahead requests will be dropped silently.

    Provided the Number of threads per node * Number of nodes < the maximum backlog, only one node in the cluster will refresh a given key at a time.

    Author:
    cschanck
    • Constructor Detail

      • RefreshAheadCache

        public RefreshAheadCache​(Ehcache adaptedCache,
                                 RefreshAheadCacheConfiguration refreshConfig)
        Create a Refresh Ahead Cache Adaptor with the specified configuration. An auxiliary EhCache Cache will be created for the purposes of synchronization, so only one node in a clustered environment will refresh a key at a given time.
        Parameters:
        adaptedCache -
        refreshConfig -
    • Method Detail

      • getRefreshSuccessCount

        public long getRefreshSuccessCount()
        number of refreshes processed locally.
      • getOfferCount

        public long getOfferCount()
        Gets offer count.
        Returns:
        the offer count
      • getDroppedCount

        public long getDroppedCount()
        Gets dropped count.
        Returns:
        the dropped count
      • getProcessedCount

        public long getProcessedCount()
        Gets processed count.
        Returns:
        the processed count
      • getBacklogCount

        public long getBacklogCount()
        Gets backlog count.
        Returns:
        the backlog count
      • findRefreshedStatistic

        public static java.util.Set<ExtendedStatistics.Statistic<java.lang.Number>> findRefreshedStatistic​(Ehcache cache)
        Find refreshed counter statistic.
        Parameters:
        cache - the cache this statistic is attached to.
        Returns:
        the set
      • findOfferStatistic

        public static java.util.Set<ExtendedStatistics.Statistic<java.lang.Number>> findOfferStatistic​(Ehcache cache)
        Find offer statistic.
        Parameters:
        cache - the cache this statistic is attached to.
        Returns:
        the set
      • findDroppedStatistic

        public static java.util.Set<ExtendedStatistics.Statistic<java.lang.Number>> findDroppedStatistic​(Ehcache cache)
        Find dropped statistic.
        Parameters:
        cache - the cache
        Returns:
        the set
      • findProcessedStatistic

        public static java.util.Set<ExtendedStatistics.Statistic<java.lang.Number>> findProcessedStatistic​(Ehcache cache)
        Find processed statistic.
        Parameters:
        cache - the cache
        Returns:
        the set
      • findBacklogStatistic

        public static java.util.Set<ExtendedStatistics.Statistic<java.lang.Number>> findBacklogStatistic​(Ehcache cache)
        Find backlog statistic.
        Parameters:
        cache - the cache
        Returns:
        the set