import { cacheLogger } from "@/services/dataCache/logger"

import { cacheMap } from "./cacheMap"

export async function deleteKey(key: string, opts?: { fuzzy?: boolean }) {
  cacheLogger.debug("Deleting key", key)
  if (opts?.fuzzy) {
    cacheMap.forEach((_, k) => {
      if (k.includes(key)) {
        cacheMap.delete(k)
      }
    })
    return
  }

  cacheMap.delete(key)
}
