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


PHP Redis::lPop方法代码示例

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


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

示例1: pop

 public static function pop($key)
 {
     $redis = self::instance();
     if ($redis) {
         self::$redis->lPop($key);
     }
 }
开发者ID:aoyel,项目名称:pinst,代码行数:7,代码来源:RedisQuery.php

示例2: receive

 /**
  * Block until the first message arrives
  *
  * @param int $key
  * @param mixed $message
  * @return bool
  */
 public function receive($key, &$message)
 {
     while ($this->client->lSize($key) <= 0) {
         usleep(self::WAIT_USLEEP);
     }
     $message = $this->client->lPop($key);
     return true;
 }
开发者ID:alexanderc,项目名称:threadator,代码行数:15,代码来源:Redis.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: testlistTrim

 public function testlistTrim()
 {
     $this->redis->delete('list');
     $this->redis->lPush('list', 'val');
     $this->redis->lPush('list', 'val2');
     $this->redis->lPush('list', 'val3');
     $this->redis->listTrim('list', 0, 0);
     $this->assertEquals(1, $this->redis->lSize('list'));
     $this->assertEquals('val', $this->redis->lPop('list'));
 }
开发者ID:hieutrieu,项目名称:phpredis,代码行数:10,代码来源:TestRedis.php

示例5: statusCheck

 public function statusCheck()
 {
     $redis = new Redis();
     $settings = $this->__getSetSettings();
     $redis->connect($settings['redis_host'], $settings['redis_port']);
     $redis->select($settings['redis_database']);
     $redis->rPush($settings['redis_namespace'] . ':command', 'status');
     sleep(1);
     $response = trim($redis->lPop($settings['redis_namespace'] . ':status'));
     return json_decode($response, true);
 }
开发者ID:humbertcostas,项目名称:MISP,代码行数:11,代码来源:PubSubTool.php

示例6: testlistTrim

 public function testlistTrim()
 {
     $this->redis->delete('list');
     $this->redis->lPush('list', 'val');
     $this->redis->lPush('list', 'val2');
     $this->redis->lPush('list', 'val3');
     $this->redis->lPush('list', 'val4');
     $this->assertEquals(TRUE, $this->redis->listTrim('list', 0, 2));
     $this->assertEquals(3, $this->redis->lSize('list'));
     $this->redis->listTrim('list', 0, 0);
     $this->assertEquals(1, $this->redis->lSize('list'));
     $this->assertEquals('val4', $this->redis->lPop('list'));
     $this->assertEquals(TRUE, $this->redis->listTrim('list', 10, 10000));
     $this->assertEquals(TRUE, $this->redis->listTrim('list', 10000, 10));
     // test invalid type
     $this->redis->set('list', 'not a list...');
     $this->assertEquals(FALSE, $this->redis->listTrim('list', 0, 2));
 }
开发者ID:0,项目名称:phpredis,代码行数:18,代码来源:TestRedis.php

示例7: getMessage

 /**
  * Get message from queue
  *
  * @return \Apple\ApnPush\Notification\MessageInterface|null
  *
  * @throws \RuntimeException
  */
 public function getMessage()
 {
     static $useSleep = false;
     if (!$this->listKey) {
         throw new \RuntimeException('Can\'t get message. Undefined list key.');
     }
     if (!$this->redis) {
         throw new \RuntimeException('Can\'t get message. Not found redis instance.');
     }
     if ($useSleep && $this->sleepTimeout) {
         usleep($this->sleepTimeout);
     }
     if ($data = $this->redis->lPop($this->listKey)) {
         $useSleep = false;
         return unserialize($data);
     } else {
         $useSleep = true;
     }
     return null;
 }
开发者ID:sgmendez,项目名称:AppleApnPush,代码行数:27,代码来源:RedisAdapter.php

示例8: Redis

 function subscribe_run()
 {
     $this->load->config('redis');
     $redis_config = $this->config->item('redis');
     $redis = new Redis();
     $redis->pconnect($redis_config['write']['hostname'], $redis_config['write']['port']);
     while (true) {
         try {
             $data = $redis->lPop(Config::$subscribe_queue_redis_key);
             if ($data) {
                 $redis->incr("dy_lzl_success");
                 $path = __DIR__;
                 $app_path = FCPATH;
                 $cmd = "/bin/sh " . $path . "/push.sh '{$app_path}' '{$data}' ";
                 $redis->set("cmd", $cmd);
                 @system($cmd, $return);
             }
         } catch (Exception $e) {
             $redis->incr("dy_lzl_error");
         }
     }
 }
开发者ID:songliang89,项目名称:my-ci,代码行数:22,代码来源:Splitindex.php

示例9: pop

 /**
  * @inheritdoc
  */
 public function pop()
 {
     return $this->redis->lPop($this->name);
 }
开发者ID:s1lent1um,项目名称:traktor,代码行数:7,代码来源:RedisQueue.php

示例10: popFirst

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

示例11: lPop

 /**
  * @param string $key
  * @return string
  */
 public function lPop($key)
 {
     $this->_useCnt++;
     return $this->_wrapBoolReturn(function () use($key) {
         return parent::lPop($key);
     });
 }
开发者ID:telander,项目名称:waka,代码行数:11,代码来源:Wk_Redis.php

示例12: foreach

$redis->connect('127.0.0.1');
if ($argv[1] == "start") {
    if ($redis->exists('get_price_pids')) {
        echo "get price daemon may already start.";
        exit;
    }
    echo "start\n\r";
    foreach ($market_list as $market) {
        echo "start market : {$market} \n\r";
        system("/usr/local/bin/php {$path}/get_price.php {$market}");
    }
    exit;
}
if ($argv[1] == "stop") {
    echo "stop\n\r";
    $pid = $redis->lPop('get_price_pids');
    while (!empty($pid)) {
        system("kill -9 {$pid}");
        echo "stop pid : {$pid} \n\r";
        $pid = $redis->lPop('get_price_pids');
    }
    exit;
}
echo "restart\n\r";
$pid = $redis->lPop('get_price_pids');
while (!empty($pid)) {
    system("kill -9 {$pid}");
    echo "stop pid : {$pid} \n\r";
    $pid = $redis->lPop('get_price_pids');
}
foreach ($market_list as $market) {
开发者ID:Aimsam,项目名称:BTCAutoTrade,代码行数:31,代码来源:cache_price.php

示例13: 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

示例14: 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


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