import Redis from "ioredis";
import { env } from "~/env";

let keydb: Redis | null = null;

export function getKeydbClient() {
	if (env.SKIP_REDIS === "true") {
		return null;
	}
	if (!keydb) {
		keydb = new Redis(`keydb://${env.KEYDB_URL}`);
	}
	return keydb;
}
