Class CaffeineExpiringCache

  • All Implemented Interfaces:

    
    public class CaffeineExpiringCache<K extends Object, V extends Object>
    
                        

    A Caffeine-backed alternative to ai.platon.pulsar.common.concurrent.ConcurrentExpiringLRUCache that exposes the same putDatum / getDatum / remove / clear / size API for drop-in compatibility.

    Entries are evicted via Caffeine's Window TinyLFU policy when the cache exceeds capacity, and expire after ttl regardless of access.

    • Constructor Detail

      • CaffeineExpiringCache

        CaffeineExpiringCache(Duration ttl, Long capacity)
    • Method Detail

      • getDatum

         final V getDatum(K key)

        Retrieve a non-expired item (Caffeine handles time-based expiry automatically).

      • getDatum

         final V getDatum(K key, Duration expires, Instant now)

        Retrieve an item with an additional caller-specified expiry window.

        Caffeine already expires entries based on the cache-level TTL, but callers may pass a tighter expires duration + now to reject entries that are technically in the cache but older than the caller's threshold.

        NOTE: The caller is responsible for checking the returned value's own timestamp (e.g. ai.platon.pulsar.persist.WebPage.prevFetchTime) via options.isExpired().

      • clear

         final Unit clear()

        Remove all entries.

      • stats

         final CacheStats stats()