Setu-TS
    Preparing search index...

    Class MemoryStore

    In-memory cache implementation with LRU eviction and lazy TTL expiry.

    On get of a live entry, the entry is deleted and re-inserted (moves to MRU position). On set, if the map exceeds maxSize, the oldest entry (first Map key) is evicted. Expired entries are lazily deleted on read (get/has).

    The constructor accepts a prefix for interface parity with other backends, but MemoryStore intentionally does not use it: each plugin instance owns its own Map, so emptying it in clear() naturally scopes to this instance.

    0.1.0

    Implements

    • CacheStore
    Index
    • Parameters

      • _prefix: string
      • Optionaloptions: { clock?: ClockFn; maxSize?: number }

        Configuration

        • Optionalclock?: ClockFn

          Monotonic clock function (default bound performance.now)

        • OptionalmaxSize?: number

          Maximum entry count (default 1000)

      Returns MemoryStore

    • Remove all entries scoped to this backend's prefix.

      The prefix is provided at construction time (not per-call), so each backend can scope the clear appropriately:

      • Redis: SCAN MATCH ${prefix}* + batch DEL
      • Memory: empty the internal map (each plugin instance owns its own map, so it naturally holds only this prefix's keys)

      Returns Promise<void>

    • Delete a value. The key is already-prefixed by CacheService.

      Parameters

      • key: string

        Already-prefixed cache key

      Returns Promise<boolean>

      true if removed

    • Read a value. The key is already-prefixed by CacheService.

      Type Parameters

      • T

        Expected value type

      Parameters

      • key: string

        Already-prefixed cache key

      Returns Promise<T | null>

      The deserialized value, or null when absent/expired

    • Check existence. The key is already-prefixed by CacheService.

      Parameters

      • key: string

        Already-prefixed cache key

      Returns Promise<boolean>

      true if present and unexpired

    • Lifecycle truth (M90b): an in-process Map has no separate backend to reach, so reachability IS readiness — the process either holds the map or it does not.

      Returns Promise<boolean>

      true when connected

      0.5.0

    • Write a value. The key is already-prefixed by CacheService.

      Type Parameters

      • T

        Value type

      Parameters

      • key: string

        Already-prefixed cache key

      • value: T

        Value to store

      • OptionalttlSeconds: number

        Optional TTL in seconds

      Returns Promise<void>