RTCForge API Reference v1.1.1
    Preparing search index...

    Interface StateStore

    Async key/value store with optional per-key time-to-live (TTL).

    This is the seam RTCForge uses for shared state (room state, session data, and so on). The default in-process implementation is MemoryStateStore; production deployments can supply an adapter backed by Redis or another store. Values are stored as-is and are typed only by the caller-supplied type parameter — no runtime validation is performed.

    interface StateStore {
        delete(key: string): Promise<void>;
        get<T>(key: string): Promise<T | undefined>;
        has(key: string): Promise<boolean>;
        keys(prefix?: string): Promise<string[]>;
        set<T>(key: string, value: T, ttlMs?: number): Promise<void>;
    }

    Implemented by

    Index

    Methods

    • Removes the entry at key, if any.

      Parameters

      • key: string

        The key to delete.

      Returns Promise<void>

    • Reads the value stored at key.

      Type Parameters

      • T

        Expected type of the stored value.

      Parameters

      • key: string

        The key to read.

      Returns Promise<T | undefined>

      The stored value, or undefined if the key is absent or expired.

    • Reports whether a live (non-expired) entry exists at key.

      Parameters

      • key: string

        The key to test.

      Returns Promise<boolean>

      true if a non-expired value is present.

    • Lists the keys of all live entries, optionally filtered by prefix.

      Parameters

      • Optionalprefix: string

        When provided, only keys starting with this string are returned.

      Returns Promise<string[]>

      The matching keys.

    • Writes a value at key, optionally with a TTL after which it expires.

      Type Parameters

      • T

        Type of the value being stored.

      Parameters

      • key: string

        The key to write.

      • value: T

        The value to store.

      • OptionalttlMs: number

        Optional lifetime in milliseconds; if omitted the entry never expires.

      Returns Promise<void>