當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。