Logos DX
    Preparing search index...

    Interface CacheAdapter<T>

    Cache adapter interface for pluggable storage backends.

    All methods are async to support Redis, IndexedDB, and other async backends. Adapters handle their own LRU eviction and cleanup logic.

    interface CacheAdapter<T> {
        size: number;
        clear(): Promise<void>;
        delete(key: string): Promise<boolean>;
        get(key: string): Promise<CacheItem<T> | null>;
        has(key: string): Promise<boolean>;
        set(key: string, item: CacheItem<T>, expiresAt?: number): Promise<void>;
    }

    Type Parameters

    • T

      The type of cached values

    Index

    Properties

    Methods

    Properties

    size: number

    Current number of cached items (may include expired items).

    Methods

    • Remove all cached items.

      Returns Promise<void>

    • Remove specific key. Returns true if existed.

      Parameters

      • key: string

      Returns Promise<boolean>

    • Retrieve cache item by key. Returns undefined if missing.

      Parameters

      • key: string

      Returns Promise<CacheItem<T> | null>

    • Check if key exists (may still be expired - adapter handles expiration).

      Parameters

      • key: string

      Returns Promise<boolean>

    • Store cache item with given key.

      Parameters

      • key: string

        Cache key

      • item: CacheItem<T>

        Cache item with value and metadata

      • OptionalexpiresAt: number

        Optional expiration timestamp for backends like Redis

      Returns Promise<void>