@pwngh/economy-lab
    Preparing search index...

    Interface Cache

    Optional read-through cache for hot reads such as balances; best-effort, so any error degrades to a direct ledger read.

    Storage for the best-effort cache contract.

    interface Cache {
        get(key: string): Promise<string | null>;
        invalidate(key: string): Promise<void>;
        set(key: string, value: string, ttlMs?: number): Promise<void>;
    }
    Index
    • The cached string, or null on a miss or an expired entry; the core's read path treats a throwing get as a miss.

      Parameters

      • key: string

      Returns Promise<string | null>

    • Removes the key so the next get reads through; a missing key is a no-op. The core calls it after a commit changes a cached balance, and a failed invalidate only logs — give entries a lifetime if a pinned stale value is unacceptable.

      Parameters

      • key: string

      Returns Promise<void>

    • Stores value whole, overwriting any previous entry. ttlMs bounds the entry's life; without it the entry lives until invalidated or evicted, and eviction at any time is legal — every read tolerates a miss.

      Parameters

      • key: string
      • value: string
      • OptionalttlMs: number

      Returns Promise<void>