Setu-TS
    Preparing search index...

    Class CacheService

    Service layer that delegates to a backend CacheStore while applying:

    • Key prefix: Prepended to all keyed operations (get/set/delete/ has). The prefix is also passed to the backend at construction so that clear() can scope to it.
    • Default TTL: Used when set() is called without ttlSeconds.

    When its CachePlugin was opted into diagnostics (M98i), each backend call is additionally counted — getOrSet's internal get and set included. A service constructed directly carries no collector and runs unobserved.

    0.1.0

    Implements

    Index
    • Parameters

      • backend: CacheStore

        The CacheStore backend implementation

      • prefix: string

        Key prefix prepended to all keyed operations. Also passed to the backend constructor for clear() scoping.

      • OptionaldefaultTtl: number

        Default TTL in seconds applied when set() omits ttlSeconds

      Returns CacheService

    • Reads a cached value or produces and stores it once for all concurrent callers of this service and key.

      The in-flight registry is cleared after either success or failure. A rejected factory therefore leaves no poisoned entry and the next caller gets a fresh attempt. The factory result is written with the same explicit or default TTL resolution as set.

      Type Parameters

      • T

        Value type associated with key

      Parameters

      • key: string

        Cache key without the service prefix

      • factory: () => Promise<T>

        Work that produces a value when the key is absent

      • OptionalttlSeconds: number

        Optional TTL override for the produced value

      Returns Promise<T>

      The cached or newly-produced value

      0.5.0

    • Stores a value.

      Type Parameters

      • T

        The value type

      Parameters

      • key: string

        Cache key

      • value: T

        Value to store

      • OptionalttlSeconds: number

        Time-to-live in seconds; omit for the store default

      Returns Promise<void>