@theophilusdev/conduit
    Preparing search index...

    Class ConduitSlidingCache<T>

    A sliding-expiry cache with in-flight deduplication.

    Each cache entry's TTL is reset on every read, meaning entries only expire if they go untouched for ttlInMS milliseconds — hence "sliding" window.

    In-flight tracking prevents duplicate concurrent fetches for the same key.

    Type Parameters

    • T

      The type of value stored in the cache.

    Index

    Constructors

    Methods

    Constructors

    Methods

    • Retrieves a cached value by key, or initializes it via initFn if absent.

      If the key exists in the cache, its expiry is slid forward and the cached value is returned immediately without invoking initFn.

      If a fetch for this key is already in-flight, the pending request is reused and initFn is not called again.

      Otherwise, initFn is called to produce the value, which is then cached.

      Parameters

      • key: string

        The cache key to look up or populate.

      • initFn: () => T | Promise<T>

        A factory function (sync or async) that produces the value if not cached.

      Returns Promise<T>

      The cached or freshly initialized value.