本文整理汇总了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;
}
示例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();
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例7: lpop
public function lpop($key, $value)
{
return parent::lpop($this->generateUniqueKey($key), $value);
}
示例8: removeCurrent
public function removeCurrent()
{
$this->redis->lpop($this->tube);
}
示例9: pop
public function pop()
{
return $this->redis->lpop($this->key);
}
示例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++;
}
}
示例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;
示例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;
示例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();
}
}
示例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"