Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

feat: allow redis connection via connection string (#2409)

Max Deichmann2084f69bec6f
diff --git a/worker/src/env.ts b/worker/src/env.ts
index 1f68354a36..e0356428f2 100644
--- a/worker/src/env.ts
+++ b/worker/src/env.ts
@@ -24,6 +24,7 @@ const EnvSchema = z.object({
.max(65536, `options.port should be >= 0 and < 65536`)
.default(6379),
REDIS_AUTH: z.string(),
+ REDIS_CONNECTION_STRING: z.string().optional(),
LANGFUSE_WORKER_PASSWORD: z.string(),
S3_ACCESS_KEY_ID: z.string().optional(),
S3_SECRET_ACCESS_KEY: z.string().optional(),
diff --git a/worker/src/redis.ts b/worker/src/redis.ts
index 5739125246..945f843829 100644
--- a/worker/src/redis.ts
+++ b/worker/src/redis.ts
@@ -4,12 +4,14 @@ import logger from "./logger";
const createRedisClient = () => {
try {
- return new Redis({
- host: env.REDIS_HOST,
- port: env.REDIS_PORT,
- password: env.REDIS_AUTH,
- maxRetriesPerRequest: null, // Set to `null` to disable retrying
- });
+ return env.REDIS_CONNECTION_STRING
+ ? new Redis(env.REDIS_CONNECTION_STRING)
+ : new Redis({
+ host: env.REDIS_HOST,
+ port: env.REDIS_PORT,
+ password: env.REDIS_AUTH,
+ maxRetriesPerRequest: null, // Set to `null` to disable retrying
+ });
} catch (e) {
logger.error(e, "Failed to connect to redis");
return null;