/** * Returns the cardinality of an ordered set. * * @param string $key * * @return int the set's cardinality * @link http://redis.io/commands/zsize * @example * <pre> * $redis->zAdd('key', 0, 'val0'); * $redis->zAdd('key', 2, 'val2'); * $redis->zAdd('key', 10, 'val10'); * $redis->zCard('key'); // 3 * </pre> */ public function zCard($key) { try { return $this->client->zCard($key); } catch (Exception $e) { return $this->handleException($e, __FUNCTION__, func_get_args()); } }
public function testZPopRevRange() { $key = 'testZPopRevRange'; $this->redis->del($key); $this->assertSame(3, $this->redis->zAdd($key, array(123 => 1.0, 456 => 1.25, 789 => 0.9))); $this->assertTrue($this->redis->multi()); $this->assertTrue($this->redis->zrevrange($key, 0, 0, true)); $this->assertTrue($this->redis->zremrangebyrank($key, -1, -1)); $this->assertSame(array(array(456 => '1.25'), 1), $this->redis->exec()); $this->assertSame(2, $this->redis->zCard($key)); }