UNPKG

asset-price-mcp

Version:

An MCP-compatible service that provides real-time asset prices including precious metals, cryptocurrencies, and more

28 lines (27 loc) 628 B
export class SimpleCache { cache = new Map(); ttl; constructor(ttlMs = 60000) { this.ttl = ttlMs; } get(key) { const entry = this.cache.get(key); if (!entry) return null; if (Date.now() - entry.timestamp > this.ttl) { this.cache.delete(key); return null; } return entry.data; } set(key, data) { this.cache.set(key, { data, timestamp: Date.now() }); } clear() { this.cache.clear(); } } export const apiCache = new SimpleCache(60000); // Default 1 min cache