Skip to main content
Glama
cache.ts697 B
export interface CacheEntry<T> { value: T; expiresAt: number; } export class InMemoryCache { private store = new Map<string, CacheEntry<unknown>>(); constructor(private readonly defaultTtlMs = 0) {} get<T>(key: string): T | null { const entry = this.store.get(key); if (!entry) return null; if (entry.expiresAt && entry.expiresAt < Date.now()) { this.store.delete(key); return null; } return entry.value as T; } set<T>(key: string, value: T, ttlMs?: number): void { const expiresAt = ttlMs === undefined ? this.defaultTtlMs : ttlMs; this.store.set(key, { value, expiresAt: expiresAt ? Date.now() + expiresAt : 0, }); } }

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/seovimalraj/locations'

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