Skip to content

Commit

Permalink
Added sample .env Redis variables and improved regex on keyvRedis.js …
Browse files Browse the repository at this point in the history
…file.
  • Loading branch information
gafda committed Feb 14, 2025
1 parent 47f3a78 commit 069c08d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
13 changes: 10 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -495,16 +495,23 @@ HELP_AND_FAQ_URL=https://librechat.ai
# Google tag manager id
#ANALYTICS_GTM_ID=user provided google tag manager id

#===============#
# REDIS Options #
#===============#

# REDIS_URI=10.10.10.10:6379
# USE_REDIS=true

# USE_REDIS_CLUSTER=true
# REDIS_CA=/path/to/ca.crt

#==================================================#
# Others #
#==================================================#
# You should leave the following commented out #

# NODE_ENV=

# REDIS_URI=
# USE_REDIS=

# E2E_USER_EMAIL=
# E2E_USER_PASSWORD=

Expand Down
5 changes: 1 addition & 4 deletions api/cache/keyvRedis.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
const KeyvRedis = require('@keyv/redis');
const { isEnabled } = require('~/server/utils');
<<<<<<< HEAD
const logger = require('~/config/winston');
=======
const fs = require('fs');
const ioredis = require('ioredis');
>>>>>>> 82717228 (feat: Enhance Redis support with cluster configuration and TLS options)

const { REDIS_URI, USE_REDIS, USE_REDIS_CLUSTER, REDIS_CA } = process.env;

let keyvRedis;

function mapURI(uri) {
const regex = /^(?<scheme>[a-zA-Z]+):\/\/(?<user>[^:]*):?(?<password>[^@]*)?@?(?<host>[^:\/]+):?(?<port>\d+)?/;
const regex = /^(?:(?<scheme>\w+):\/\/)?(?:(?<user>[^:@]+)(?::(?<password>[^@]+))?@)?(?<host>[\w.-]+)(?::(?<port>\d{1,5}))?$/;
const match = uri.match(regex);

if (match) {
Expand Down

0 comments on commit 069c08d

Please sign in to comment.