当前位置: 首页>>代码示例>>PHP>>正文


PHP Redis::rPop方法代码示例

本文整理汇总了PHP中Redis::rPop方法的典型用法代码示例。如果您正苦于以下问题:PHP Redis::rPop方法的具体用法?PHP Redis::rPop怎么用?PHP Redis::rPop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Redis的用法示例。


在下文中一共展示了Redis::rPop方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get

 /**
  * get value from the queue
  *
  * @param bool $block if block when the queue is empty
  * @return bool|string
  */
 public function get($block = false)
 {
     if (!$block) {
         return $this->redis->rPop($this->channel);
     } else {
         while (true) {
             $record = $this->redis->rPop($this->channel);
             if ($record === false) {
                 usleep(1000);
                 continue;
             }
             return $record;
         }
     }
 }
开发者ID:huyanping,项目名称:simple-fork-php,代码行数:21,代码来源:RedisQueue.php

示例2: rPop

 /**
  * Remove and return a value from a list
  *
  * @param string $key
  * @return string|null
  */
 public function rPop($key)
 {
     $result = $this->_redis->rPop($key);
     if (false === $result) {
         $result = null;
     }
     return $result;
 }
开发者ID:aladin1394,项目名称:CM,代码行数:14,代码来源:Client.php

示例3: testDifferentTypeHash

 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));
 }
开发者ID:Jerry-Shaw,项目名称:phpredis,代码行数:56,代码来源:RedisTest.php

示例4: pop

 /**
  * 返回队列中的第一个元素(从底部)
  * @param bool $bak 当bak为TRUE时,则会自动将队列数据备份至kbak
  * @return string $v
  */
 public function pop($bak = TRUE)
 {
     try {
         if ($bak) {
             return $this->rd->rpoplpush($this->k, $this->kbak);
         } else {
             return $this->rd->rPop($this->k);
         }
     } catch (\RedisException $e) {
         if ($this->reconnRedis()) {
             if ($bak) {
                 return $this->rd->rpoplpush($this->k, $this->kbak);
             } else {
                 return $this->rd->rPop($this->k);
             }
         }
     }
     return FALSE;
 }
开发者ID:seepre,项目名称:api.seepre.com,代码行数:24,代码来源:RedQueue.php

示例5: testrPop

 public function testrPop()
 {
     //	rpush  => tail
     //	lpush => head
     $this->redis->delete('list');
     $this->redis->rPush('list', 'val');
     $this->redis->rPush('list', 'val2');
     $this->redis->lPush('list', 'val3');
     // 'list' = [ 'val3', 'val', 'val2']
     $this->assertEquals('val2', $this->redis->rPop('list'));
     $this->assertEquals('val', $this->redis->rPop('list'));
     $this->assertEquals('val3', $this->redis->rPop('list'));
     $this->assertEquals(FALSE, $this->redis->rPop('list'));
     // testing binary data
     $this->redis->delete('list');
     $this->assertEquals(1, $this->redis->rPush('list', gzcompress('val1')));
     $this->assertEquals(2, $this->redis->rPush('list', gzcompress('val2')));
     $this->assertEquals(3, $this->redis->rPush('list', gzcompress('val3')));
     $this->assertEquals('val3', gzuncompress($this->redis->rPop('list')));
     $this->assertEquals('val2', gzuncompress($this->redis->rPop('list')));
     $this->assertEquals('val1', gzuncompress($this->redis->rPop('list')));
 }
开发者ID:0,项目名称:phpredis,代码行数:22,代码来源:TestRedis.php

示例6: popLast

 /**
  * Remove and return the last element of the list.
  * 
  * @return Bdes\Q\Item the last element of the list
  */
 public function popLast()
 {
     return $this->redis->rPop($this->listName);
 }
开发者ID:BD-ES,项目名称:Q,代码行数:9,代码来源:Redis.php

示例7: rpop

 /**
  * rpop a raw value
  *
  * @param	string	$key	Cache ID
  * @param	string	$value	value
  * @return	mixed	New value on success or FALSE on failure
  */
 public function rpop($key)
 {
     return $this->_redis->rPop($key);
 }
开发者ID:asmenglei,项目名称:lanxiao,代码行数:11,代码来源:Cache_redis.php

示例8: dequeue

 /**
  * 从Redis队列中读取一条任务
  *
  * @param string $queue Redis队列名
  *
  * @return string JSON格式字符串
  */
 public function dequeue($queue)
 {
     return $this->redis->rPop($queue);
 }
开发者ID:emilymwang8,项目名称:ajk-broker,代码行数:11,代码来源:RedisCount.php

示例9: pop

 /**
  * 数据出队列
  * @param string $key KEY名称
  * @param bool $left 是否从左边开始出数据
  * @return array
  */
 public function pop($key, $left = true)
 {
     $val = $left ? parent::lPop($key) : parent::rPop($key);
     return json_decode($val, true);
 }
开发者ID:cloklo,项目名称:CxWoole,代码行数:11,代码来源:CxRedis.php

示例10: listPop

 /**
  * 出队列
  * @param $list1 string 队列名
  * @param $deriction int 0:数据入队列头(左) 1:数据入队列尾(右) 默认为0
  * @param $list2 string 第二个队列名 默认null
  * @param $timeout int timeout为0:只获取list1队列的数据 
  *        timeout>0:如果队列list1为空 则等待timeout秒 如果还是未获取到数据 则对list2队列执行pop操作
  */
 public static function listPop($list1, $deriction = 0, $list2 = null, $timeout = 0)
 {
     $redis = new \Redis();
     $redis->connect(self::_HOST, self::_PORT);
     $return = null;
     switch ($direction) {
         case 0:
             if ($timeout && $list2) {
                 $return = $redis->blPop($list1, $list2, $timeout);
             } else {
                 $return = $redis->lPop($list1);
             }
             break;
         case 1:
             if ($timeout && $list2) {
                 $return = $redis->brPop($list1, $list2, $timeout);
             } else {
                 $return = $redis->rPop($list1);
             }
             break;
         default:
             $return = false;
             break;
     }
     $redis->close();
     $redis = null;
     return $return;
 }
开发者ID:skyshow,项目名称:ticket,代码行数:36,代码来源:MyRedis.class.php

示例11: get

 /**
  * get value from the queue of channel
  * @param $channel
  * @return mixed
  */
 public function get($channel)
 {
     return $this->redis->rPop($channel);
 }
开发者ID:jzxyouok,项目名称:simple-fork-php,代码行数:9,代码来源:RedisQueue.php

示例12: pop

 /**
  * 数据出队列(对应redis的list数据结构)
  * @param string $key KEY名称
  * @param bool $left 是否从左边开始出数据
  * @return mixed
  */
 public function pop($key)
 {
     $val = $this->redis->rPop($key);
     return json_decode($val);
 }
开发者ID:WALES7CH,项目名称:TP-Admin,代码行数:11,代码来源:RedisHandler.class.php

示例13: date

            } else {
                continue;
            }
        }
        file_put_contents(__DIR__ . '/log/import_error_' . date('Ymd') . '.log', '[' . date('H:i:s') . ']' . "Process import sleep...\n", FILE_APPEND);
        sleep(1);
    }
}
if ('worker' === $_GET['step']) {
    // list num
    $list_id = $_GET['list'];
    // save worker pid
    $pidfile = __DIR__ . '/log/import_workers/LOG_LIST_' . $list_id . '.pid';
    file_put_contents($pidfile, posix_getpid());
    // redis cluster
    $redis_cluster = new Redis();
    if (!$redis_cluster->connect('192.168.4.105', 8002)) {
        throw new Exception("Ubhvrcache redis(192.168.4.105:8002) unavailable.");
    }
    // log redis
    $redis = new Redis();
    $redis->connect('127.0.0.1', 5379);
    // consump redis list
    $key = 'LOG_LIST_' . $list_id;
    while ($message = $redis->rPop($key)) {
        // parse message...
        // save cache...
    }
    // delete pid file when worker ends
    unlink($pidfile);
}
开发者ID:sdgdsffdsfff,项目名称:twemproxy-redis-helper,代码行数:31,代码来源:import.php

示例14: rpop

 public function rpop($channel)
 {
     return $this->client->rPop($channel);
 }
开发者ID:yoye,项目名称:redis-broker,代码行数:4,代码来源:PhpRedisAdapter.php


注:本文中的Redis::rPop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。