Esempio n. 1
0
 public function testZPopRangeByScore()
 {
     $key = 'foo';
     $this->_client->zAdd($key, 1, 'foo');
     $this->_client->zAdd($key, 1.5, 'bar');
     $this->_client->zAdd($key, 2, 'foobar');
     $this->assertSame(array('foo', 'bar', 'foobar'), $this->_client->zRangeByScore($key, '1', '2'));
     $removedValues = $this->_client->zPopRangeByScore($key, '1.2', '1.8');
     $this->assertSame(array('bar'), $removedValues);
     $this->assertSame(2, $this->_client->zCard($key));
     $removedValues = $this->_client->zPopRangeByScore($key, '0.8', '1.2', true);
     $this->assertSame(array('foo', '1'), $removedValues);
     $this->assertSame(1, $this->_client->zCard($key));
 }
Esempio n. 2
0
 public function testZRangeByScore()
 {
     $key = 'foo';
     $this->_client->zAdd($key, 1, 'foo');
     $this->_client->zAdd($key, 1.5, 'bar');
     $this->_client->zAdd($key, 2, 'foobar');
     // normal behaviour
     $this->assertSame(array('foo', 'bar', 'foobar'), $this->_client->zRangeByScore($key, 1, 2));
     // count
     $this->assertSame(array('foo', 'bar'), $this->_client->zRangeByScore($key, 1, 2, 2));
     // offset
     $this->assertSame(array('bar', 'foobar'), $this->_client->zRangeByScore($key, 1, 2, null, 1));
     // withscores
     $this->assertSame(array('foo' => '1', 'bar' => '1.5', 'foobar' => '2'), $this->_client->zRangeByScore($key, 1, 2, null, null, true));
     $this->assertSame(array(), $this->_client->zRangeByScore($key, 1, 2, 0, 0));
 }