starting caching work

This commit is contained in:
2025-03-11 23:54:03 -07:00
parent a6ecf7df88
commit 1520dd830c
3 changed files with 35 additions and 27 deletions

27
config/redis.ts Normal file
View File

@@ -0,0 +1,27 @@
import { createClient } from "redis";
import curriedLogger from "../utils/logger.ts";
import { sleep } from "../utils/flake.ts";
const logger = curriedLogger(import.meta.filename);
if (!process.env["REDIS_URI"])
throw new TypeError("Redis connection URI not defined");
// Initialize
const redisClient: ReturnType<typeof createClient> = createClient({
url: process.env["REDIS_URI"],
});
// Check connection
(async () => {
try {
await redisClient.connect();
while (!redisClient.isReady) await sleep(100);
logger.info("Connected to Redis store");
} catch (error) {
logger.error("Redis connection error", { error });
throw error;
}
})();
export { redisClient };