mirror of
https://github.com/predis/predis.git
synced 2026-09-07 08:58:33 +00:00
Fix SlotMap::offsetUnset() corrupting mappings when unsetting a slot in a gap (#1660)
This commit is contained in:
+5
-2
@@ -2,11 +2,14 @@
|
||||
|
||||
## Unreleased
|
||||
### Added
|
||||
- Added support for GCRA command (#1657)
|
||||
- Handle `-READONLY` responses in Redis Cluster for AWS ElastiCache Redis OSS failover events
|
||||
- Added support for `GCRA` command (#1657)
|
||||
- Handle Redis Cluster `-READONLY` responses failover events (#1656)
|
||||
|
||||
### Changed
|
||||
- Include command name in unsupported container command error messages (#1653)
|
||||
|
||||
### Fixed
|
||||
- Fixed handling of gap slots in `SlotMap::offsetUnset()` (#1660)
|
||||
|
||||
## v3.4.2 (2026-03-09)
|
||||
### Changed
|
||||
|
||||
@@ -264,6 +264,7 @@ class SlotMap implements ArrayAccess, IteratorAggregate, Countable
|
||||
foreach ($this->slotRanges as $slotRange) {
|
||||
if (!$slotRange->hasSlot($slot)) {
|
||||
$results[] = $slotRange;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (static::isValidRange($slotRange->getStart(), $slot - 1)) {
|
||||
|
||||
@@ -403,6 +403,25 @@ class SlotMapTest extends PredisTestCase
|
||||
$this->assertFalse(isset($slotmap[5461]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group disconnected
|
||||
*/
|
||||
public function testOffsetUnsetDoesNotPolluteSlotMapOnGapSlot(): void
|
||||
{
|
||||
$slotmap = new SlotMap();
|
||||
|
||||
$slotmap->setSlots(0, 100, '127.0.0.1:6379');
|
||||
$slotmap->setSlots(200, 300, '127.0.0.1:6380');
|
||||
|
||||
$this->assertFalse(isset($slotmap[150]));
|
||||
$this->assertNull($slotmap[150]);
|
||||
|
||||
unset($slotmap[150]);
|
||||
|
||||
$this->assertFalse(isset($slotmap[150]));
|
||||
$this->assertNull($slotmap[150]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group disconnected
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user