/** * @pwngh/economy-lab * * Copyright (c) Preston Neal * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */ import type { Cache, Clock } from '../ports.js'; /** * Builds an in-process {@link Cache} backed by a `Map`. It exposes the same observable contract as * the Redis adapter. The Cache conformance suite runs it as its oracle, the way `memoryStore` is the * reference for the Store. It also serves as a usable single-process cache when no Redis is wired. * * It honors `ttlMs` against the injected `clock`. An entry past its expiry reads as a miss, the same * way Redis's `PX` flag expires a key, so the conformance suite can drive expiry with a fake clock. * Values are opaque strings, and this never parses them. * * @example * const cache = memoryCache(); * await cache.set('bal:usr_42:spendable', 'CREDIT:12.34', 60_000); * await cache.get('bal:usr_42:spendable'); // 'CREDIT:12.34' | null * * @see {@link https://economy-lab-docs.pages.dev/economy/ports/storage/ Storage} for the cache and store port contracts. */ export declare function memoryCache(clock?: Clock): Cache;