Skip to main content
Glama
heyzgj

CoinMarketCap Universal MCP Server

by heyzgj
cache.ts1.17 kB
/** * Simple in-memory cache manager * Provides caching functionality to reduce API calls */ export class CacheManager { private cache: Map<string, { data: any; expiry: number }> = new Map(); /** * Retrieves data from cache if available and not expired * @param key Cache key * @returns Cached data or null if not found or expired */ async get<T>(key: string): Promise<T | null> { const item = this.cache.get(key); if (!item) return null; if (item.expiry < Date.now()) { this.cache.delete(key); return null; } return item.data as T; } /** * Stores data in cache with expiration * @param key Cache key * @param data Data to cache * @param ttlSeconds Time to live in seconds */ async set(key: string, data: any, ttlSeconds: number): Promise<void> { const expiry = Date.now() + ttlSeconds * 1000; this.cache.set(key, { data, expiry }); } /** * Clears all cached data */ clear(): void { this.cache.clear(); } /** * Removes a specific item from cache * @param key Cache key to remove */ remove(key: string): void { this.cache.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/heyzgj/mcp-feargreedindex'

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