mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-09 12:08:50 +01:00
📡 refactor: MCP Runtime Config Sync with Redis Distributed Locking (#10352)
* 🔄 Refactoring: MCP Runtime Configuration Reload
- PrivateServerConfigs own cache classes (inMemory and Redis).
- Connections staleness detection by comparing (connection.createdAt and config.LastUpdatedAt)
- ConnectionsRepo access Registry instead of in memory config dict and renew stale connections
- MCPManager: adjusted init of ConnectionsRepo (app level)
- UserConnectionManager: renew stale connections
- skipped test, to test "should only clear keys in its own namespace"
- MCPPrivateServerLoader: new component to manage logic of loading / editing private servers on runtime
- PrivateServersLoadStatusCache to track private server cache status
- New unit and integration tests.
Misc:
- add es lint rule to enforce line between class methods
* Fix cluster mode batch update and delete workarround. Fixed unit tests for cluster mode.
* Fix Keyv redis clear cache namespace awareness issue + Integration tests fixes
* chore: address copilot comments
* Fixing rebase issue: removed the mcp config fallback in single getServerConfig method:
- to not to interfere with the logic of the right Tier (APP/USER/Private)
- If userId is null, the getServerConfig should not return configs that are a SharedUser tier and not APP tier
* chore: add dev-staging branch to workflow triggers for backend, cache integration, and ESLint checks
---------
Co-authored-by: Atef Bellaaj <slalom.bellaaj@external.daimlertruck.com>
This commit is contained in:
parent
52e6796635
commit
ac68e629e6
49 changed files with 5244 additions and 257 deletions
27
packages/api/src/cache/cacheConfig.ts
vendored
27
packages/api/src/cache/cacheConfig.ts
vendored
|
|
@ -85,6 +85,33 @@ const cacheConfig = {
|
|||
DEBUG_MEMORY_CACHE: isEnabled(process.env.DEBUG_MEMORY_CACHE),
|
||||
|
||||
BAN_DURATION: math(process.env.BAN_DURATION, 7200000), // 2 hours
|
||||
|
||||
/**
|
||||
* Number of keys to delete in each batch during Redis DEL operations.
|
||||
* In cluster mode, keys are deleted individually in parallel chunks to avoid CROSSSLOT errors.
|
||||
* In single-node mode, keys are deleted in batches using DEL with arrays.
|
||||
* Lower values reduce memory usage but increase number of Redis calls.
|
||||
* @default 1000
|
||||
*/
|
||||
REDIS_DELETE_CHUNK_SIZE: math(process.env.REDIS_DELETE_CHUNK_SIZE, 1000),
|
||||
|
||||
/**
|
||||
* Number of keys to update in each batch during Redis SET operations.
|
||||
* In cluster mode, keys are updated individually in parallel chunks to avoid CROSSSLOT errors.
|
||||
* In single-node mode, keys are updated in batches using transactions (multi/exec).
|
||||
* Lower values reduce memory usage but increase number of Redis calls.
|
||||
* @default 1000
|
||||
*/
|
||||
REDIS_UPDATE_CHUNK_SIZE: math(process.env.REDIS_UPDATE_CHUNK_SIZE, 1000),
|
||||
|
||||
/**
|
||||
* COUNT hint for Redis SCAN operations when scanning keys by pattern.
|
||||
* This is a hint to Redis about how many keys to scan in each iteration.
|
||||
* Higher values can reduce round trips but increase memory usage and latency per call.
|
||||
* Note: Redis may return more or fewer keys than this count depending on internal heuristics.
|
||||
* @default 1000
|
||||
*/
|
||||
REDIS_SCAN_COUNT: math(process.env.REDIS_SCAN_COUNT, 1000),
|
||||
};
|
||||
|
||||
export { cacheConfig };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue