import type { RequiredAfterSearchRates } from "./types"; interface SuccessCacheEntry { rates: RequiredAfterSearchRates; updatedAt: number; } export function createMarketCacheStore() { const successCache = new Map(); const inflightRequests = new Map>(); return { clearInflight(authorId: string) { inflightRequests.delete(authorId); }, getInflight(authorId: string) { return inflightRequests.get(authorId) as Promise | undefined; }, getSuccess(authorId: string) { return successCache.get(authorId); }, setInflight(authorId: string, promise: Promise) { inflightRequests.set(authorId, promise); }, setSuccess(authorId: string, rates: RequiredAfterSearchRates) { successCache.set(authorId, { rates, updatedAt: Date.now() }); } }; }