Skip to main content
Glama
cache.ts723 B
export interface CacheEntry<T> { value: T; expiresAt: number; } export class TTLCache<K, V> { private readonly store = new Map<K, CacheEntry<V>>(); constructor(private readonly ttlMs: number) {} get(key: K): V | 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; } set(key: K, value: V): void { this.store.set(key, { value, expiresAt: Date.now() + this.ttlMs, }); } clear(key?: K): void { if (typeof key === 'undefined') { this.store.clear(); } else { this.store.delete(key); } } }

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/keithah/plex-mcp-account-finder'

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