import { type CacheTime, getCacheTimeInSeconds } from "../../Cache" import { cacheLogger } from "../../logger" import { cacheMap } from "./cacheMap" export async function set( key: string, data: T, ttl: CacheTime ): Promise { const cacheTimeInSeconds = getCacheTimeInSeconds(ttl) if (cacheTimeInSeconds <= 0) { cacheLogger.info(`'Trying to set ${key}' with ttl=0. Skipping cache!`) return } cacheMap.set(key, { data: data, expiresAt: Date.now() + cacheTimeInSeconds * 1000, }) }