Interface Policy.CacheEntry<K,​V>

  • All Superinterfaces:
    Map.Entry<K,​V>
    Enclosing interface:
    Policy<K,​V>

    public static interface Policy.CacheEntry<K,​V>
    extends Map.Entry<K,​V>
    A key-value pair that may include policy metadata for the cached entry. Unless otherwise specified, this is a value-based class, it can be assumed that the implementation is an immutable snapshot of the cached data at the time of this entry's creation, and it will not reflect changes afterwards.
    • Method Detail

      • weight

        int weight()
        Returns the entry's weight. If the cache was not configured with a maximum weight then this value is always 1.
        Returns:
        the weight if the entry
      • expiresAt

        long expiresAt()
        Returns the Ticker.read() ticks for when this entry expires. If the cache was not configured with an expiration policy then this method always around Long.MAX_VALUE ticks from the snapshotAt() reading.
        Returns:
        the ticker reading for when the entry expires
      • expiresAfter

        default Duration expiresAfter()
        Returns the duration between expiresAt() and snapshotAt().
        Returns:
        the length of time after which the entry will be automatically removed
      • refreshableAt

        long refreshableAt()
        Returns the Ticker.read() ticks for when this entry becomes refreshable. If the cache was not configured with a refresh policy then always around Long.MAX_VALUE ticks from the snapshotAt() reading.
        Returns:
        the ticker reading for when the entry may be refreshed
      • refreshableAfter

        default Duration refreshableAfter()
        Returns the duration between refreshableAt() and snapshotAt().
        Returns:
        the length of time after which an entry is eligible to be reloaded
      • snapshotAt

        long snapshotAt()
        Returns the Ticker.read() ticks for when this snapshot of the entry was taken. This reading may be a constant if no time-based policy is configured.
        Returns:
        the ticker reading for when this snapshot of the entry was taken.