public function testRemoveItemsSync() { $this->redis->zadd('test', [1 => self::TIME_MOCK - 10, 3 => self::TIME_MOCK - 5, 5 => self::TIME_MOCK - 2 + 600.1, 7 => self::TIME_MOCK + 600.1, 9 => self::TIME_MOCK + 5]); $pool = new Pool($this->redis, 'test', [Base::OPT_SLAVES_SYNC_ENABLED => true, Base::OPT_SLAVES_SYNC_REQUIRED_COUNT => 5], $this->getTimeMock()); try { $pool->removeItems([7, 5, 3]); } catch (\PhpRQ\Exception\NotEnoughSlavesSynced $e) { } $this->assertSame(3, $this->redis->zcard('test')); $items = $this->redis->zrange('test', 0, 5); $this->assertTrue(in_array('1', $items, true)); $this->assertTrue(in_array('3', $items, true)); $this->assertTrue(in_array('9', $items, true)); $this->assertKeys(['test']); }
public function testRemoveItems() { $time = time(); $this->redis->zadd('test', [1 => $time - 10, 3 => $time - 5, 5 => $time - 2 + 600.1, 7 => $time + 600.1, 9 => $time + 5]); $pool = new Pool($this->redis, 'test'); $pool->removeItems([1]); $pool->removeItems([7, 5]); $this->assertSame(3, $this->redis->zcard('test')); $items = $this->redis->zrange('test', 0, 5); $this->assertTrue(in_array('1', $items, true)); $this->assertTrue(in_array('3', $items, true)); $this->assertTrue(in_array('9', $items, true)); $this->assertKeys(['test']); }
public function testRemoveItems() { $this->redis->zadd('test', [1 => self::TIME_MOCK - 10, 3 => self::TIME_MOCK - 5, 5 => self::TIME_MOCK - 2 + 600.1, 7 => self::TIME_MOCK + 600.1, 9 => self::TIME_MOCK + 5]); $pool = new Pool($this->redis, 'test', [], $this->getTimeMock()); $pool->removeItems([1]); $pool->removeItems([7, 5]); $this->assertSame(3, $this->redis->zcard('test')); $items = $this->redis->zrange('test', 0, 5); $this->assertTrue(in_array('1', $items, true)); $this->assertTrue(in_array('3', $items, true)); $this->assertTrue(in_array('9', $items, true)); $this->assertKeys(['test']); }