Interface Policy.FixedRefresh<K,​V>

  • Enclosing interface:
    Policy<K,​V>

    public static interface Policy.FixedRefresh<K,​V>
    The low-level operations for a cache with a fixed refresh policy.
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default Optional<Duration> ageOf​(K key)
      Returns the age of the entry based on the expiration policy.
      OptionalLong ageOf​(K key, TimeUnit unit)
      Returns the age of the entry based on the refresh policy.
      default Duration getRefreshesAfter()
      Returns the fixed duration used to determine if an entry should be eligible for reloading due to elapsing this time bound.
      @org.checkerframework.checker.index.qual.NonNegative long getRefreshesAfter​(TimeUnit unit)
      Returns the fixed duration used to determine if an entry should be eligible for reloading due to elapsing this time bound.
      void setRefreshesAfter​(@org.checkerframework.checker.index.qual.NonNegative long duration, TimeUnit unit)
      Specifies that each entry should be eligible for reloading once a fixed duration has elapsed.
      default void setRefreshesAfter​(Duration duration)
      Specifies that each entry should be eligible for reloading once a fixed duration has elapsed.
    • Method Detail

      • ageOf

        OptionalLong ageOf​(K key,
                           TimeUnit unit)
        Returns the age of the entry based on the refresh policy. The entry's age is the cache's estimate of the amount of time since the entry's refresh time was last reset.

        An expiration policy uses the age to determine if an entry is fresh or stale by comparing it to the freshness lifetime. This is calculated as fresh = freshnessLifetime > age where freshnessLifetime = expires - currentTime.

        This method is scheduled for removal in version 3.0.0.

        Parameters:
        key - the key for the entry being queried
        unit - the unit that age is expressed in
        Returns:
        the age if the entry is present in the cache
      • ageOf

        default Optional<Duration> ageOf​(K key)
        Returns the age of the entry based on the expiration policy. The entry's age is the cache's estimate of the amount of time since the entry's expiration was last reset.

        An expiration policy uses the age to determine if an entry is fresh or stale by comparing it to the freshness lifetime. This is calculated as fresh = freshnessLifetime > age where freshnessLifetime = expires - currentTime.

        Parameters:
        key - the key for the entry being queried
        Returns:
        the age if the entry is present in the cache
      • getRefreshesAfter

        @org.checkerframework.checker.index.qual.NonNegative long getRefreshesAfter​(TimeUnit unit)
        Returns the fixed duration used to determine if an entry should be eligible for reloading due to elapsing this time bound. An entry is considered fresh if its age is less than this duration, and stale otherwise. The refresh policy determines when the entry's age is reset.

        This method is scheduled for removal in version 3.0.0.

        Parameters:
        unit - the unit that duration is expressed in
        Returns:
        the length of time after which an entry is eligible to be reloaded
      • getRefreshesAfter

        default Duration getRefreshesAfter()
        Returns the fixed duration used to determine if an entry should be eligible for reloading due to elapsing this time bound. An entry is considered fresh if its age is less than this duration, and stale otherwise. The refresh policy determines when the entry's age is reset.
        Returns:
        the length of time after which an entry is eligible to be reloaded
      • setRefreshesAfter

        void setRefreshesAfter​(@org.checkerframework.checker.index.qual.NonNegative long duration,
                               TimeUnit unit)
        Specifies that each entry should be eligible for reloading once a fixed duration has elapsed. The refresh policy determines when the entry's age is reset.

        This method is scheduled for removal in version 3.0.0.

        Parameters:
        duration - the length of time after which an entry is eligible to be reloaded
        unit - the unit that duration is expressed in
        Throws:
        IllegalArgumentException - if duration is negative
      • setRefreshesAfter

        default void setRefreshesAfter​(Duration duration)
        Specifies that each entry should be eligible for reloading once a fixed duration has elapsed. The refresh policy determines when the entry's age is reset.
        Parameters:
        duration - the length of time after which an entry is eligible to be reloaded
        Throws:
        IllegalArgumentException - if duration is negative