Interface TtlPolicy

All Known Implementing Classes:
TtlPolicy.AdaptiveTtl, TtlPolicy.Eternal, TtlPolicy.FixedTtl, TtlPolicy.PerKeyTtl, TtlPolicy.SlidingTtl

Sealed interface defining various TTL (Time-To-Live) policies for cache entries.

Each policy determines how long an entry remains valid and how its TTL changes based on access patterns. Policies include:

  • FixedTtl: constant TTL for all entries
  • SlidingTtl: TTL resets on each access
  • AdaptiveTtl: TTL based on access frequency (hot keys get longer TTL)
  • PerKeyTtl: each key has individually set TTL
  • Eternal: never expires

Implementations are immutable and thread-safe.

Since:
1.5
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final record 
    Adaptive TTL policy: TTL based on access frequency.
    static final record 
    Eternal policy: entries never expire.
    static final record 
    Fixed TTL policy: entries have a constant TTL regardless of access.
    static final record 
    Per-key TTL policy: each key has its own individually set TTL.
    static final record 
    Sliding TTL policy: TTL resets on each access.