import {
  type CacheTime,
  getCacheTimeInSeconds,
} from "@/services/dataCache/Cache"

import { cacheMap } from "./cacheMap"

export async function set<T>(
  key: string,
  data: T,
  ttl: CacheTime
): Promise<void> {
  cacheMap.set(key, {
    data: data,
    expiresAt: Date.now() + getCacheTimeInSeconds(ttl) * 1000,
  })
}
