Setu-TS
    Preparing search index...

    Interface ICacheStore

    Key/value cache with per-entry TTL.

    const cache = ctx.services.get<ICacheStore>(CAPABILITIES.CACHE);
    await cache.set('user:123', user, 3600);
    const cached = await cache.get<User>('user:123');

    0.1.0

    interface ICacheStore {
        clear(): Promise<void>;
        delete(key: string): Promise<boolean>;
        get<T>(key: string): Promise<T | null>;
        has(key: string): Promise<boolean>;
        set<T>(key: string, value: T, ttlSeconds?: number): Promise<void>;
    }

    Implemented by

    Index
    • Removes a cached value.

      Parameters

      • key: string

        Cache key

      Returns Promise<boolean>

      true if an entry was removed

    • Reads a cached value.

      Type Parameters

      • T

        The expected value type

      Parameters

      • key: string

        Cache key

      Returns Promise<T | null>

      The value, or null when absent or expired

    • Reports whether a live entry exists.

      Parameters

      • key: string

        Cache key

      Returns Promise<boolean>

      true if present and unexpired

    • 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>