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


PHP Redis::lpop方法代码示例

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


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

示例1: flushQueue

 /**
  * {@inheritdoc}
  */
 public function flushQueue(\Swift_Transport $transport, &$failedRecipients = null)
 {
     if (!$this->redis->llen($this->key)) {
         return 0;
     }
     if (!$transport->isStarted()) {
         $transport->start();
     }
     $failedRecipients = (array) $failedRecipients;
     $count = 0;
     $time = time();
     while ($message = unserialize($this->redis->lpop($this->key))) {
         $count += $transport->send($message, $failedRecipients);
         if ($this->getMessageLimit() && $count >= $this->getMessageLimit()) {
             break;
         }
         if ($this->getTimeLimit() && time() - $time >= $this->getTimeLimit()) {
             break;
         }
     }
     return $count;
 }
开发者ID:jayesbe,项目名称:SncRedisBundle,代码行数:25,代码来源:RedisSpool.php

示例2: doQueue

function doQueue()
{
    global $statusArr;
    $pid = posix_getpid();
    $statusArr[$pid]++;
    $redis = new Redis();
    $redis->connect('127.0.0.1', '6379');
    // 这个中间可以是处理逻辑
    $data = "you are so beautiful!";
    $key = "test:lo";
    $redis->rpush($key, $data);
    $data = $redis->lpop($key);
    $redis->close();
}
开发者ID:luoqing,项目名称:simpleSocketCode,代码行数:14,代码来源:localCommu.php

示例3: redisConsumerAction

 public function redisConsumerAction()
 {
     $config = Yaf_Application::app()->getConfig();
     $queue = 'test_queue';
     $host = $config['redis_host'];
     $port = $config['redis_port'];
     $redis = new Redis();
     $redis->connect($host, $port);
     $data = $redis->lpop($queue);
     echo $data;
     die;
 }
开发者ID:xujunjiepk,项目名称:YOF,代码行数:12,代码来源:Profile.php

示例4: Redis

<?php

$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
$redis->select(2);
$channel = $argv[1];
// channel
while (TRUE) {
    $data = array();
    while ($msg = $redis->lpop('channel' . $channel)) {
        $data[] = $msg;
    }
    print_r($data);
    sleep(1);
}
开发者ID:whenjonny,项目名称:queue-demo,代码行数:15,代码来源:lpop.php

示例5: Redis

$log->info("Starting feedwriter process");
// Connect to redis
$redis = new Redis();
while (!$redis->connect("127.0.0.1")) {
    sleep(1);
    $log->warn("Could not connect to redis, retrying");
}
require "Modules/feed/engine/PHPTimeSeries.php";
require "Modules/feed/engine/PHPFina.php";
$engine = array();
$engine[Engine::PHPTIMESERIES] = new PHPTimeSeries($feed_settings['phptimeseries']);
$engine[Engine::PHPFINA] = new PHPFina($feed_settings['phpfina']);
while (true) {
    $len = $redis->llen("feedbuffer");
    for ($i = 0; $i < $len; $i++) {
        $f = explode(",", $redis->lpop("feedbuffer"));
        $feedid = $f[0];
        $timestamp = $f[1];
        $value = $f[2];
        $padding_mode = (int) $f[3];
        $e = $redis->hget("feed:{$feedid}", 'engine');
        if ($padding_mode == 1) {
            $engine[Engine::PHPFINA]->padding_mode = 'join';
        }
        $engine[$e]->prepare($feedid, $timestamp, $value);
        $engine[Engine::PHPFINA]->padding_mode = 'nan';
    }
    $log->info("PHPTimeSeries bytes written: " . $engine[Engine::PHPTIMESERIES]->save());
    $log->info("PHPFina bytes written: " . $engine[Engine::PHPFINA]->save());
    sleep(60);
}
开发者ID:roy13,项目名称:EMON,代码行数:31,代码来源:feedwriter.php

示例6: getMap

 function getMap($pid = 0)
 {
     if ($pid <= 0) {
         return;
     }
     $redis = new Redis();
     $redis->pconnect('127.0.0.1', 6379);
     $map = $redis->get('map');
     if (!$map) {
         $tid = $redis->lpop('free');
         $map = array($pid => $tid);
         $redis->set('map', json_encode($map));
     } else {
         $map = json_decode($map, true);
         $tid = $map[$pid];
     }
     //var_dump('map', $map, 'tid', $tid,'pid:', $pid);
     return $tid;
 }
开发者ID:hytzxd,项目名称:swoole-doc,代码行数:19,代码来源:ServerCommand.php

示例7: lpop

 public function lpop($key, $value)
 {
     return parent::lpop($this->generateUniqueKey($key), $value);
 }
开发者ID:nbaiwan,项目名称:yav,代码行数:4,代码来源:CRedis.php

示例8: removeCurrent

 public function removeCurrent()
 {
     $this->redis->lpop($this->tube);
 }
开发者ID:huoybb,项目名称:standard,代码行数:4,代码来源:myRedisQueue.php

示例9: pop

 public function pop()
 {
     return $this->redis->lpop($this->key);
 }
开发者ID:justthefish,项目名称:hesper,代码行数:4,代码来源:RedisNoSQLList.php

示例10: Redis

<?php

$redis = new Redis();
$redis->connect("127.0.0.1");
$i = 0;
while (true) {
    if (time() - $ltime > 1) {
        $ltime = time();
        print $i . "\n";
        $i = 0;
    }
    if ($redis->llen('myqueue') > 0) {
        // check if there is an item in the queue to process
        $line_str = $redis->lpop('myqueue');
        $i++;
    }
}
开发者ID:jurviz,项目名称:development,代码行数:17,代码来源:redis_sub.php

示例11: explode

     // if throughput is low then increase sleep significantly
     if ($rn == 0) {
         $usleep = 100000;
     }
     // sleep cant be less than zero
     if ($usleep < 0) {
         $usleep = 0;
     }
     echo "Buffer length: " . $buflength . " " . $usleep . " " . $rn . "\n";
     $rn = 0;
 }
 // check if there is an item in the queue to process
 $line_str = false;
 if ($redis->llen('buffer') > 0) {
     // check if there is an item in the queue to process
     $line_str = $redis->lpop('buffer');
 }
 if ($line_str) {
     $rn++;
     // echo $line_str."\n";
     $line_parts = explode(',', $line_str);
     // The first and second value in the csv is userid, time and nodeid
     $userid = $line_parts[0];
     $time = $line_parts[1];
     $nodeid = $line_parts[2];
     // Load current user input meta data
     // It would be good to avoid repeated calls to this
     $dbinputs = $input->get_inputs($userid);
     $tmp = array();
     // For each node input
     $name = 1;
开发者ID:jurviz,项目名称:development,代码行数:31,代码来源:input_queue_auth_in_publisher.php

示例12: Redis

<?php

$redis = new Redis();
$redis->connect("127.0.0.1", "6379");
// string
$redis->delete("KeyTime");
$redis->mset(array('key111' => "key111", "key222" => "key222"));
echo (int) $redis->exists("key111");
$array = $redis->getMultiple(array("key111", "key222"));
echo "<br>";
print_r($array);
for ($i = 0; $i < 10; $i++) {
    $redis->lpush("list", $i);
}
$redis->lpop("list");
$redis->rpop("list");
echo $redis->lsize("list");
echo $redis->lget("list", 0);
echo $redis->lset("list", 1, "new_value");
$data = $redis->lRange("list", 0, -1);
echo "<pre>";
print_r($data);
$bool = $redis->ltrim("list", 0, 5);
echo $redis->lrem("list", "5");
$bool = $redis->rpoplpush("srcKey", "dstKey");
// SET
for ($i = 0; $i < 10; $i++) {
    $redis->sadd("myset", $i + rand(10, 99));
}
$bool = $redis->srem("myset", 16);
echo (int) $bool;
开发者ID:isS,项目名称:NoSQL,代码行数:31,代码来源:redisWithPHP.php

示例13: Redis

<?php

header('Content-Type: text/event-stream;charset=UTF-8');
header('Cache-Control: no-cache');
header("Connection: keep-alive");
set_time_limit(0);
$objRedis = new Redis();
$objRedis->connect("localhost");
$numStateEvents = $objRedis->llen('eventQueue');
for ($i = 0; $i < $numStateEvents; $i++) {
    $objRedis->lpop('eventQueue');
}
while (true) {
    $event = $objRedis->lpop('eventQueue');
    if ($event) {
        echo "data: {$event}\n\n";
        ob_flush();
        flush();
    }
}
开发者ID:aninternetof,项目名称:rovercode,代码行数:20,代码来源:event-notifier.php

示例14:

//结果:int(3)
var_dump($redis->rpush("test", "444")) . '<br>';
//结果:int(4)
/**
lpop

描述:返回和移除列表的第一个元素
参数:key
返回值:成功返回第一个元素的值 ,失败返回false
*/
$redis->delete('test');
$redis->lpush("test", "111");
$redis->lpush("test", "222");
$redis->rpush("test", "333");
$redis->rpush("test", "444");
var_dump($redis->lpop("test")) . '<br>';
//结果:string(3) "222"
/**
rpop

描述:返回和移除列表的最后一个元素
参数:key
返回值:成功返回最后一个元素的值 ,失败返回false
*/
$redis->delete('test');
$redis->lpush("test", "111");
$redis->lpush("test", "222");
$redis->rpush("test", "333");
$redis->rpush("test", "444");
var_dump($redis->rpop("test")) . '<br>';
//结果:string(3) "444"
开发者ID:wujunze,项目名称:bigpan,代码行数:31,代码来源:redis.php


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