Skip to content

Commit 02a49ac

Browse files
committed
docs: Document Redis cluster-safe deletes
1 parent 08709ad commit 02a49ac

2 files changed

Lines changed: 56 additions & 27 deletions

File tree

content/docs/configuration/dotenv.mdx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2735,6 +2735,12 @@ For detailed configuration and examples, see: **[Redis Configuration Guide](/doc
27352735
'Enable Redis cluster mode when using a single URI',
27362736
'# USE_REDIS_CLUSTER="true"',
27372737
],
2738+
[
2739+
'REDIS_CLUSTER_SAFE_DELETE',
2740+
'boolean',
2741+
'Delete Redis cache keys individually to avoid CROSSSLOT errors on single-endpoint managed Redis services that shard keys internally.',
2742+
'# REDIS_CLUSTER_SAFE_DELETE=true',
2743+
],
27382744
[
27392745
'REDIS_USERNAME',
27402746
'string',
@@ -2796,6 +2802,7 @@ Notes:
27962802

27972803
- When `USE_REDIS=true`, you must provide `REDIS_URI` or the application will throw an error.
27982804
- For Redis Cluster mode, provide multiple URIs: `redis://node1:7001,redis://node2:7002,redis://node3:7003` (cluster mode is auto-detected).
2805+
- For single-endpoint managed Redis services that shard keys internally, keep `USE_REDIS_CLUSTER=false` and set `REDIS_CLUSTER_SAFE_DELETE=true` if cache clears fail with `CROSSSLOT` errors.
27992806
- Use `rediss://` protocol for TLS connections and set `REDIS_CA` if your CA is not publicly trusted.
28002807
- `REDIS_KEY_PREFIX_VAR` and `REDIS_KEY_PREFIX` are mutually exclusive.
28012808
- **AWS Elasticache with TLS**: Elasticache may need to use an alternate dnsLookup for TLS connections. Set `REDIS_USE_ALTERNATIVE_DNS_LOOKUP=true` if using Elasticache with TLS. See [ioredis documentation](https://www.npmjs.com/package/ioredis) for more details.

content/docs/configuration/redis.mdx

Lines changed: 49 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,21 @@ REDIS_URI=redis://127.0.0.1:7001
6161
USE_REDIS_CLUSTER=true
6262
```
6363

64+
### Single-Endpoint Managed Redis Services
65+
66+
Some managed Redis services, including AWS ElastiCache Serverless and Redis Enterprise Cloud on AWS, expose a single connection endpoint while sharding keys internally. In that setup, keep LibreChat in single-node connection mode, but enable cluster-safe deletes if cache clears fail with `CROSSSLOT Keys in request don't hash to the same slot`.
67+
68+
```bash
69+
USE_REDIS=true
70+
REDIS_URI=rediss://your-managed-redis-endpoint:6379
71+
USE_REDIS_CLUSTER=false
72+
REDIS_CLUSTER_SAFE_DELETE=true
73+
```
74+
75+
`REDIS_CLUSTER_SAFE_DELETE=true` makes LibreChat delete matching cache keys one at a time instead of sending multi-key `DEL` commands. This avoids `CROSSSLOT` errors without changing how LibreChat connects to Redis.
76+
77+
Use `USE_REDIS_CLUSTER=true` only when LibreChat should create a Redis Cluster client. For single-endpoint managed services, `REDIS_CLUSTER_SAFE_DELETE=true` is the safer option.
78+
6479
### Redis with TLS/SSL
6580

6681
For secure Redis connections:
@@ -104,9 +119,10 @@ REDIS_URI=rediss://your-redis-host:6380
104119
# Provide CA certificate for verification
105120
REDIS_CA=/path/to/your/ca-certificate.pem
106121
```
122+
107123
### TLS with Elasticache
108124

109-
Elasticache may need to use an alternate dnsLookup for TLS connections. see "Special Note: Aws Elasticache Clusters with TLS" on this webpage: https://www.npmjs.com/package/ioredis
125+
Elasticache may need to use an alternate dnsLookup for TLS connections. see "Special Note: Aws Elasticache Clusters with TLS" on this webpage: https://www.npmjs.com/package/ioredis
110126

111127
```bash
112128
# Enable redis alternate dnsLookup
@@ -153,11 +169,13 @@ REDIS_KEY_PREFIX=dev-john-local
153169
**Important**: You cannot set both `REDIS_KEY_PREFIX_VAR` and `REDIS_KEY_PREFIX` simultaneously.
154170

155171
**Examples of contamination without prefixing**:
172+
156173
- Production cache overwritten by staging deployment
157174
- Feature branch tests corrupting main branch cache
158175
- Old deployment versions serving stale cached data
159176

160177
**Key prefixing format**:
178+
161179
- IoRedis client: `{prefix}::{key}`
162180
- Keyv client: Handled by the store layer
163181

@@ -183,6 +201,7 @@ REDIS_PING_INTERVAL=300
183201
```
184202

185203
**Important**:
204+
186205
- Setting `REDIS_PING_INTERVAL=0` or omitting it disables pinging entirely
187206
- Only set a positive value (in seconds) if you experience connection timeout issues
188207
- The interval is specified in seconds and applies to both IoRedis and Keyv Redis clients
@@ -199,40 +218,42 @@ FORCED_IN_MEMORY_CACHE_NAMESPACES=ROLES,MESSAGES
199218

200219
Valid cache keys (from the `CacheKeys` enum in `librechat-data-provider`):
201220

202-
| Key | Description |
203-
|---|---|
204-
| `CONFIG_STORE` | Configuration store |
205-
| `ROLES` | User roles |
206-
| `PLUGINS` | Plugins data |
207-
| `GEN_TITLE` | Generated titles |
208-
| `TOOLS` | Tools data |
209-
| `MODELS_CONFIG` | Models configuration |
210-
| `MODEL_QUERIES` | Model queries |
211-
| `STARTUP_CONFIG` | Startup configuration |
212-
| `ENDPOINT_CONFIG` | Endpoint configuration |
213-
| `TOKEN_CONFIG` | Token configuration |
214-
| `APP_CONFIG` | Application configuration |
215-
| `ABORT_KEYS` | Abort keys |
216-
| `BANS` | Ban data |
217-
| `ENCODED_DOMAINS` | Encoded domains |
218-
| `AUDIO_RUNS` | Audio processing runs |
219-
| `MESSAGES` | Messages |
220-
| `FLOWS` | Flows data |
221-
| `PENDING_REQ` | Pending requests |
222-
| `S3_EXPIRY_INTERVAL` | S3 expiry intervals |
223-
| `OPENID_EXCHANGED_TOKENS` | OpenID exchanged tokens |
224-
| `OPENID_SESSION` | OpenID sessions |
225-
| `SAML_SESSION` | SAML sessions |
221+
| Key | Description |
222+
| ------------------------- | ------------------------- |
223+
| `CONFIG_STORE` | Configuration store |
224+
| `ROLES` | User roles |
225+
| `PLUGINS` | Plugins data |
226+
| `GEN_TITLE` | Generated titles |
227+
| `TOOLS` | Tools data |
228+
| `MODELS_CONFIG` | Models configuration |
229+
| `MODEL_QUERIES` | Model queries |
230+
| `STARTUP_CONFIG` | Startup configuration |
231+
| `ENDPOINT_CONFIG` | Endpoint configuration |
232+
| `TOKEN_CONFIG` | Token configuration |
233+
| `APP_CONFIG` | Application configuration |
234+
| `ABORT_KEYS` | Abort keys |
235+
| `BANS` | Ban data |
236+
| `ENCODED_DOMAINS` | Encoded domains |
237+
| `AUDIO_RUNS` | Audio processing runs |
238+
| `MESSAGES` | Messages |
239+
| `FLOWS` | Flows data |
240+
| `PENDING_REQ` | Pending requests |
241+
| `S3_EXPIRY_INTERVAL` | S3 expiry intervals |
242+
| `OPENID_EXCHANGED_TOKENS` | OpenID exchanged tokens |
243+
| `OPENID_SESSION` | OpenID sessions |
244+
| `SAML_SESSION` | SAML sessions |
226245

227246
<Callout type="warn" title="Invalid keys">
228-
Using an invalid key (e.g., the deprecated `STATIC_CONFIG`) will cause a startup error. Only use keys from the table above.
247+
Using an invalid key (e.g., the deprecated `STATIC_CONFIG`) will cause a startup error. Only use
248+
keys from the table above.
229249
</Callout>
230250

231251
## Performance Tuning
232252

233253
### Connection Keep-Alive
234254

235255
The application implements configurable connection keep-alive:
256+
236257
- Ping intervals are controlled by `REDIS_PING_INTERVAL` environment variable
237258
- Default behavior: No pinging (recommended for most deployments)
238259
- When enabled, pings both IoRedis and Keyv Redis clients at the specified interval
@@ -241,6 +262,7 @@ The application implements configurable connection keep-alive:
241262
### Cache Strategy
242263

243264
The application uses a dual-client approach:
265+
244266
- **IoRedis client**: Primary Redis operations with automatic prefixing
245267
- **Keyv Redis client**: Store-layer operations with prefix handling in `cacheFactory.js`
246268

@@ -319,4 +341,4 @@ USE_REDIS_CLUSTER=true
319341
REDIS_URI=redis://node1:7001,redis://node2:7002,redis://node3:7003
320342
```
321343

322-
See [Resumable Streams](/docs/features/resumable_streams) for more details on this feature.
344+
See [Resumable Streams](/docs/features/resumable_streams) for more details on this feature.

0 commit comments

Comments
 (0)