Interface Policy.CacheEntry<K,V>

Type Parameters:
K - the type of keys
V - the type of values
All Superinterfaces:
Map.Entry<K,V>
Enclosing interface:
Policy<K,V>

@NullMarked 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 afterward.
  • Method Details

    • 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 value is roughly Long.MAX_VALUE ticks away 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 this value is roughly Long.MAX_VALUE ticks away 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.