import { env } from "@/env/server"

import { cacheOrGet } from "./cacheOrGet"
import { deleteKey } from "./deleteKey"
import { get } from "./get"
import { set } from "./set"

import type { DataCache } from "@/services/dataCache/Cache"

export const API_KEY = env.REDIS_API_KEY ?? ""
export async function createDistributedCache(): Promise<DataCache> {
  return {
    type: "redis",
    get,
    set,
    cacheOrGet,
    deleteKey,
  } satisfies DataCache
}
