import {CacheProvider} from './cacheProvider'; /** * In-memory cache implementation backed by a native `Map`. */ export class InMemoryCache implements CacheProvider { private cache = new Map(); public get(key: string, loader: (key: string) => Promise): Promise { return this.cache.has(key) ? Promise.resolve(this.cache.get(key)!) : loader(key); } public set(key: string, value: T): Promise { this.cache.set(key, value); return Promise.resolve(); } public delete(key: string): Promise { this.cache.delete(key); return Promise.resolve(); } }