Ejemplo n.º 1
0
 public function it_can_llen()
 {
     $this->redis->lLen('test')->shouldBeCalled()->willReturn(1);
     $this->lLen('test')->shouldReturn(1);
     $this->redis->lLen('test')->willThrow(new \RedisException());
     $this->shouldThrow(DriverException::class)->during('lLen', ['test']);
 }
Ejemplo n.º 2
0
 public static function length($key)
 {
     $redis = self::instance();
     if ($redis) {
         self::$redis->lLen($key);
     }
 }
Ejemplo n.º 3
0
 /**
  * @param string $key
  * @return int
  * @throws CM_Exception_Invalid
  */
 public function lLen($key)
 {
     $length = $this->_redis->lLen($key);
     if (false === $length) {
         throw new CM_Exception_Invalid('Key `' . $key . '` does not contain a list');
     }
     return $length;
 }
Ejemplo n.º 4
0
 public function testDifferentTypeHash()
 {
     $key = '{hash}hash';
     $dkey = '{hash}hash';
     $this->redis->del($key);
     $this->assertEquals(1, $this->redis->hSet($key, 'key', 'value'));
     // string I/F
     $this->assertEquals(FALSE, $this->redis->get($key));
     $this->assertEquals(FALSE, $this->redis->getset($key, 'value2'));
     $this->assertEquals(FALSE, $this->redis->append($key, 'append'));
     $this->assertEquals(FALSE, $this->redis->getRange($key, 0, 8));
     $this->assertEquals(array(FALSE), $this->redis->mget(array($key)));
     $this->assertEquals(FALSE, $this->redis->incr($key));
     $this->assertEquals(FALSE, $this->redis->incrBy($key, 1));
     $this->assertEquals(FALSE, $this->redis->decr($key));
     $this->assertEquals(FALSE, $this->redis->decrBy($key, 1));
     // lists I/F
     $this->assertEquals(FALSE, $this->redis->rPush($key, 'lvalue'));
     $this->assertEquals(FALSE, $this->redis->lPush($key, 'lvalue'));
     $this->assertEquals(FALSE, $this->redis->lLen($key));
     $this->assertEquals(FALSE, $this->redis->lPop($key));
     $this->assertEquals(FALSE, $this->redis->lrange($key, 0, -1));
     $this->assertEquals(FALSE, $this->redis->lTrim($key, 0, 1));
     $this->assertEquals(FALSE, $this->redis->lGet($key, 0));
     $this->assertEquals(FALSE, $this->redis->lSet($key, 0, "newValue"));
     $this->assertEquals(FALSE, $this->redis->lrem($key, 'lvalue', 1));
     $this->assertEquals(FALSE, $this->redis->lPop($key));
     $this->assertEquals(FALSE, $this->redis->rPop($key));
     $this->assertEquals(FALSE, $this->redis->rPoplPush($key, $dkey . 'lkey1'));
     // sets I/F
     $this->assertEquals(FALSE, $this->redis->sAdd($key, 'sValue1'));
     $this->assertEquals(FALSE, $this->redis->srem($key, 'sValue1'));
     $this->assertEquals(FALSE, $this->redis->sPop($key));
     $this->assertEquals(FALSE, $this->redis->sMove($key, $dkey . 'skey1', 'sValue1'));
     $this->assertEquals(FALSE, $this->redis->scard($key));
     $this->assertEquals(FALSE, $this->redis->sismember($key, 'sValue1'));
     $this->assertEquals(FALSE, $this->redis->sInter($key, $dkey . 'skey2'));
     $this->assertEquals(FALSE, $this->redis->sUnion($key, $dkey . 'skey4'));
     $this->assertEquals(FALSE, $this->redis->sDiff($key, $dkey . 'skey7'));
     $this->assertEquals(FALSE, $this->redis->sMembers($key));
     $this->assertEquals(FALSE, $this->redis->sRandMember($key));
     // sorted sets I/F
     $this->assertEquals(FALSE, $this->redis->zAdd($key, 1, 'zValue1'));
     $this->assertEquals(FALSE, $this->redis->zRem($key, 'zValue1'));
     $this->assertEquals(FALSE, $this->redis->zIncrBy($key, 1, 'zValue1'));
     $this->assertEquals(FALSE, $this->redis->zRank($key, 'zValue1'));
     $this->assertEquals(FALSE, $this->redis->zRevRank($key, 'zValue1'));
     $this->assertEquals(FALSE, $this->redis->zRange($key, 0, -1));
     $this->assertEquals(FALSE, $this->redis->zRevRange($key, 0, -1));
     $this->assertEquals(FALSE, $this->redis->zRangeByScore($key, 1, 2));
     $this->assertEquals(FALSE, $this->redis->zCount($key, 0, -1));
     $this->assertEquals(FALSE, $this->redis->zCard($key));
     $this->assertEquals(FALSE, $this->redis->zScore($key, 'zValue1'));
     $this->assertEquals(FALSE, $this->redis->zRemRangeByRank($key, 1, 2));
     $this->assertEquals(FALSE, $this->redis->zRemRangeByScore($key, 1, 2));
 }
 /**
  * return queue length
  * @return int the queue length
  */
 public function getQueueSize()
 {
     return $this->_redis->lLen($this->_queueStructName);
 }
Ejemplo n.º 6
0
 public function getRunningSize()
 {
     return (int) $this->redis->lLen($this->getTaskRunKey());
 }
Ejemplo n.º 7
0
 /**
  * lLen a raw value
  *
  * @param	string	$key	Cache ID
  * @return	mixed	Value on success or FALSE on failure
  */
 public function llen($key)
 {
     return $this->_redis->lLen($key);
 }
Ejemplo n.º 8
0
 /**
  * @inheritdoc
  */
 public function count()
 {
     $this->checkClientConnection();
     return $this->client->lLen("queue:{$this->name}:messages");
 }
Ejemplo n.º 9
0
 /**
  * 获取Redis队列长度
  *
  * @param string $queue Redis队列名
  *
  * @return int
  */
 public function length($queue)
 {
     return $this->redis->lLen($queue);
 }
Ejemplo n.º 10
0
<?php

$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
// 加上时间戳存入队列
$now_time = date("Y-m-d H:i:s");
$interface_info = array('user_uuid' => '123456df', 'comment' => 'rwesdf');
$r_len = $redis->lLen("call_log");
//    for($i = 0; $i < $r_len; $i++){
//        $redis->lPop("call_log");
//    }
$interface_info = json_encode($interface_info);
for ($i = 1; $i <= 10000; $i++) {
    $redis->rPush("call_log", $interface_info);
}