Commit aed967a
hayase_yasuhiro
Implement server-side cluster mode detection for Redis Cache
This commit implements runtime cluster mode detection using the
Redis INFO command, enabling proper handling of single-endpoint
cluster configurations (e.g., AWS Elasticache Valkey Serverless).
Implementation details:
- Add WeakMap-based cache for cluster mode detection per connection
- Query server cluster mode via INFO cluster command
- Handle different response formats between phpredis and predis:
* phpredis: ['cluster_enabled' => 1]
* predis: ['Cluster' => ['cluster_enabled' => '1']]
- Apply cluster fallback to both putMany() and many() methods
The implementation now correctly handles three connection scenarios:
1. Explicit cluster connections (PhpRedisClusterConnection,
PredisClusterConnection)
2. Single-endpoint clusters (regular connection to cluster-mode server)
3. Non-cluster Redis servers (standard behavior)
For cluster mode, cross-slot operations fall back to individual
commands to avoid CROSSSLOT, MOVED, and driver-specific errors.
Test results: 30/33 tests passing. The 3 failing tests are related
to tagged cache flush() operations, which is a separate issue with
RedisTaggedCache::flushValues() using multi-key DEL commands.
Related to PR laravel#53940 which only handled explicit cluster connection
types but not single-endpoint clusters.1 parent 9d057cc commit aed967a
1 file changed
+67
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
48 | 55 | | |
49 | 56 | | |
50 | 57 | | |
| |||
57 | 64 | | |
58 | 65 | | |
59 | 66 | | |
| 67 | + | |
60 | 68 | | |
61 | 69 | | |
62 | 70 | | |
| |||
92 | 100 | | |
93 | 101 | | |
94 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
95 | 113 | | |
96 | 114 | | |
97 | 115 | | |
| |||
132 | 150 | | |
133 | 151 | | |
134 | 152 | | |
135 | | - | |
136 | | - | |
| 153 | + | |
137 | 154 | | |
138 | 155 | | |
139 | 156 | | |
| |||
346 | 363 | | |
347 | 364 | | |
348 | 365 | | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
349 | 414 | | |
350 | 415 | | |
351 | 416 | | |
| |||
0 commit comments