-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhance Redis cluster support #5784
Conversation
e12f24e
to
f64f2d6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ESLint found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
f64f2d6
to
069c08d
Compare
api/cache/keyvRedis.js
Outdated
port: value.port | ||
}; |
Check failure
Code scanning / ESLint
Require or disallow trailing commas
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@@ -495,16 +495,23 @@ HELP_AND_FAQ_URL=https://librechat.ai | |||
# Google tag manager id | |||
#ANALYTICS_GTM_ID=user provided google tag manager id | |||
|
|||
#===============# |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two new environment variables:
Please also update the librechat docs: https://github.com/LibreChat-AI/librechat.ai/blob/main/pages/docs/configuration/dotenv.mdx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here it is!
Please let us know if you need any changes. :)
api/cache/keyvRedis.js
Outdated
keyvRedis.on('error', (err) => logger.error('KeyvRedis connection error:', err)); | ||
keyvRedis.setMaxListeners(20); | ||
keyvRedis.setMaxListeners(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is max listeners set to 0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was needed for our use case.
Since it differs from the original, I've made it customizable with REDIS_MAX_LISTENERS
instead. (Description updated.)
api/cache/keyvRedis.js
Outdated
port: port || null, | ||
}; | ||
} else { | ||
// Handle cases without a scheme |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please address linting
4cc1293
to
1e51084
Compare
api/cache/keyvRedis.js
Outdated
|
||
let keyvRedis; | ||
const redis_prefix = REDIS_KEY_PREFIX || ""; |
Check failure
Code scanning / ESLint
Enforce the consistent use of either backticks, double, or single quotes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
3608319
to
16c86dc
Compare
16c86dc
to
5d0a0eb
Compare
Thanks, merging here: #5963 |
Summary
This adds support for connecting to Redis clusters with TLS authentication, specifically enabling LibreChat to work with Google Memorystore Redis Cluster.
The changes are focused on the
api/cache/keyvRedis.js
file.Change Type
Config Changes
There are two new environment variables:
boolean
Cluster
mode to connect to Redistrue
string
/memorystore/ca
string
librechat-staging:
number
10
Testing
Regex testing:

Started a node pod in the cluster via
kubectl run --rm -it node-18 --image node:18-bullseye
(should have used node-20 but that was what the developer-defined in.devcontainer/Dockerfile
so I went with it.Then attached to that running pod via vscode: https://code.visualstudio.com/docs/devcontainers/attach-container
Checked out the code, defined my
.env
file (using the deployment env vars where required, like MongoDB or pointing to the RAG API), and used my very own vscode debug file to check my work.I was able to validate that the object is correctly recognized as a Cluster after creation:

We see the TLS definition there:

After letting the program run for a while and breaking, for instance, in here:

I can now see that the Redis client is in the

read
status.Test Configuration:
Checklist