/* In-process Map storage cache for Node/Bun */ import type { Storage, StoredEntry } from '@/lib/cache' import { wrapFetch } from '@/lib/cache' const store = new Map() export const memoryStorage = (): Storage => { const storage: Storage = { async get(key: string) { return (store.get(key) as StoredEntry) ?? null }, async set(key: string, value: T) { // Kept indefinitely, freshness is decided by the caller not by expiry store.set(key, { value, cachedAt: Date.now() }) }, fetch: async () => { throw new Error('uninit') }, } storage.fetch = wrapFetch(storage) return storage }