Skip to main content
Glama
cache.ts552 B
export class MemoryCache<T> { private store = new Map<string, { expiresAt: number; value: T }>(); constructor(private readonly ttlSeconds: number) {} public get(key: string): T | undefined { const entry = this.store.get(key); if (!entry) return undefined; if (Date.now() > entry.expiresAt) { this.store.delete(key); return undefined; } return entry.value; } public set(key: string, value: T): void { this.store.set(key, { value, expiresAt: Date.now() + this.ttlSeconds * 1000, }); } }

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/Valerio357/bet-mcp'

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