prorm API Reference
    Preparing search index...

    Interface CacheBackend

    Abstract interface for cache backend implementations

    interface CacheBackend {
        get(key: string): Promise<string | null>;
        set(key: string, value: string, ttl?: number): Promise<boolean>;
        del(key: string): Promise<boolean>;
        exists(key: string): Promise<boolean>;
        invalidatePattern(pattern: string): Promise<number>;
        clear(): Promise<boolean>;
        mget(keys: string[]): Promise<(string | null)[]>;
        mset(
            entries: { key: string; value: string; ttl?: number }[],
        ): Promise<boolean>;
        disconnect(): Promise<void>;
        isConnected(): boolean;
    }

    Implemented by

    Index
    • Get a value from cache

      Parameters

      • key: string

        Cache key

      Returns Promise<string | null>

      Cached value or null if not found

    • Set a value in cache

      Parameters

      • key: string

        Cache key

      • value: string

        Value to cache

      • Optionalttl: number

        Time to live in seconds (optional)

      Returns Promise<boolean>

      True if successful

    • Delete a key from cache

      Parameters

      • key: string

        Cache key

      Returns Promise<boolean>

      True if key was deleted

    • Check if a key exists in cache

      Parameters

      • key: string

        Cache key

      Returns Promise<boolean>

      True if key exists

    • Invalidate all keys matching a pattern

      Parameters

      • pattern: string

        Key pattern (supports glob patterns like user:*)

      Returns Promise<number>

      Number of keys invalidated

    • Clear all cache entries (use with caution)

      Returns Promise<boolean>

      True if successful

    • Get multiple keys at once

      Parameters

      • keys: string[]

        Array of cache keys

      Returns Promise<(string | null)[]>

      Array of values (null for missing keys)

    • Set multiple keys at once

      Parameters

      • entries: { key: string; value: string; ttl?: number }[]

        Array of {key, value, ttl?} objects

      Returns Promise<boolean>

      True if successful

    • Close the cache backend connection

      Returns Promise<void>

      Promise that resolves when connection is closed

    • Check if cache backend is connected

      Returns boolean

      True if connected