Commit 3964104
hayase_yasuhiro
Fix Cache::flexible() to work with Redis Cluster
The flexible() method was generating keys that could hash to different
slots in Redis Cluster, causing CROSSSLOT errors. This fix adds Redis
hash tags to ensure all related keys (value, created timestamp, and lock)
are stored in the same slot.
Changes:
- Add a 4-character MD5 hash prefix as a hash tag for slot allocation
- Wrap hash in {} to ensure consistent slot placement in Redis Cluster
- Maintain original key structure for non-cluster Redis instances
- Works with both phpredis and predis drivers
This resolves issues with AWS ElastiCache Serverless (Valkey) and other
Redis Cluster environments while remaining backward compatible with
standalone Redis instances.1 parent 0fc5528 commit 3964104
1 file changed
+16
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
488 | 488 | | |
489 | 489 | | |
490 | 490 | | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
491 | 496 | | |
492 | | - | |
493 | | - | |
494 | | - | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
495 | 500 | | |
496 | 501 | | |
497 | 502 | | |
498 | | - | |
499 | | - | |
| 503 | + | |
| 504 | + | |
500 | 505 | | |
501 | 506 | | |
502 | 507 | | |
503 | 508 | | |
504 | 509 | | |
505 | 510 | | |
506 | 511 | | |
507 | | - | |
| 512 | + | |
508 | 513 | | |
509 | | - | |
| 514 | + | |
510 | 515 | | |
511 | 516 | | |
512 | | - | |
513 | | - | |
| 517 | + | |
| 518 | + | |
514 | 519 | | |
515 | 520 | | |
516 | 521 | | |
517 | 522 | | |
518 | | - | |
519 | | - | |
| 523 | + | |
| 524 | + | |
520 | 525 | | |
521 | 526 | | |
522 | 527 | | |
| |||
0 commit comments