@shadow-dev/core
Version:
A modular core framework for Discord bot development, providing commands, buttons, menus, middleware, and more.
14 lines (12 loc) • 425 B
text/typescript
const cache = new Map<string, {data: any; expires: number}>();
export function cacheRequest<T>(key: string, data: T, ttl: number = 60000) {
cache.set(key, {data, expires: Date.now() + ttl});
}
export function getCached<T>(key: string): T | null {
const cached = cache.get(key);
if (cached && Date.now() < cached.expires) {
return cached.data;
}
cache.delete(key);
return null;
}