Commit 22054ea
authored
perf(mcp): add URL-keyed connection pooling for Redis database tools (#808)
Add a connection cache to CachedClients (keyed by resolved URL) that
returns a shared MultiplexedConnection, matching the existing pattern
used for Cloud and Enterprise API clients.
- Add `database: HashMap<String, MultiplexedConnection>` to CachedClients
- Add `redis_connection_for_url()` on AppState with PING health check
and automatic reconnect on stale connections
- Add `get_connection()` helper in tools/redis/mod.rs that combines
URL resolution and cached connection retrieval
- Replace per-handler Client::open + get_multiplexed_async_connection
boilerplate across all 55 database tool handlers
Connections are keyed by URL (not profile name) so different profiles
pointing to the same database share a connection, and raw URL callers
benefit from caching too.
Closes #8011 parent cef87d9 commit 22054ea
7 files changed
Lines changed: 246 additions & 742 deletions
File tree
- crates/redisctl-mcp/src
- tools/redis
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
| 40 | + | |
39 | 41 | | |
40 | 42 | | |
41 | 43 | | |
| |||
85 | 87 | | |
86 | 88 | | |
87 | 89 | | |
| 90 | + | |
| 91 | + | |
88 | 92 | | |
89 | 93 | | |
90 | 94 | | |
| |||
340 | 344 | | |
341 | 345 | | |
342 | 346 | | |
343 | | - | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
344 | 351 | | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
355 | 372 | | |
356 | | - | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
357 | 376 | | |
358 | 377 | | |
359 | | - | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
360 | 387 | | |
361 | 388 | | |
362 | 389 | | |
| |||
395 | 422 | | |
396 | 423 | | |
397 | 424 | | |
| 425 | + | |
| 426 | + | |
398 | 427 | | |
399 | 428 | | |
400 | 429 | | |
| |||
427 | 456 | | |
428 | 457 | | |
429 | 458 | | |
| 459 | + | |
| 460 | + | |
430 | 461 | | |
431 | 462 | | |
432 | 463 | | |
| |||
446 | 477 | | |
447 | 478 | | |
448 | 479 | | |
| 480 | + | |
| 481 | + | |
449 | 482 | | |
450 | 483 | | |
451 | 484 | | |
| |||
466 | 499 | | |
467 | 500 | | |
468 | 501 | | |
| 502 | + | |
| 503 | + | |
469 | 504 | | |
470 | 505 | | |
471 | 506 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
| 109 | + | |
| 110 | + | |
117 | 111 | | |
118 | 112 | | |
119 | 113 | | |
| |||
248 | 242 | | |
249 | 243 | | |
250 | 244 | | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
| 245 | + | |
| 246 | + | |
259 | 247 | | |
260 | 248 | | |
261 | 249 | | |
| |||
368 | 356 | | |
369 | 357 | | |
370 | 358 | | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
| 359 | + | |
| 360 | + | |
379 | 361 | | |
380 | 362 | | |
381 | 363 | | |
| |||
511 | 493 | | |
512 | 494 | | |
513 | 495 | | |
514 | | - | |
515 | | - | |
516 | | - | |
517 | | - | |
518 | | - | |
519 | | - | |
520 | | - | |
521 | | - | |
522 | | - | |
| 496 | + | |
| 497 | + | |
523 | 498 | | |
524 | 499 | | |
525 | 500 | | |
| |||
0 commit comments