Skip to main content
Glama
memory-cache.ts645 B
import type {CacheEntry} from '../types/index.js'; export class MemoryCache { private readonly cache = new Map<string, CacheEntry<any>>(); private readonly cacheTimeout: number; constructor(timeoutMs: number = 10 * 60 * 1000) { // Default 10 minutes this.cacheTimeout = timeoutMs; } get<T>(key: string): T | undefined { const cached = this.cache.get(key); if (cached && Date.now() - cached.timestamp < this.cacheTimeout) { return cached.data as T; } return undefined; } set<T>(key: string, data: T): void { this.cache.set(key, { data, timestamp: Date.now(), }); } clear(): void { this.cache.clear(); } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/MightyDillah/apple-doc-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server