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


PHP Redis::llen方法代码示例

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


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

 public function testltrim()
 {
     $this->redis->del('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->ltrim('list', 0, 2));
     $this->assertEquals(3, $this->redis->llen('list'));
     $this->redis->ltrim('list', 0, 0);
     $this->assertEquals(1, $this->redis->llen('list'));
     $this->assertEquals('val4', $this->redis->lPop('list'));
     $this->assertEquals(TRUE, $this->redis->ltrim('list', 10, 10000));
     $this->assertEquals(TRUE, $this->redis->ltrim('list', 10000, 10));
     // test invalid type
     $this->redis->set('list', 'not a list...');
     $this->assertEquals(FALSE, $this->redis->ltrim('list', 0, 2));
 }
开发者ID:Jerry-Shaw,项目名称:phpredis,代码行数:18,代码来源:RedisTest.php

示例3: Redis

$log->set_logfile("/var/log/emoncms.log");
$log->set_topic("FEEDWRITER");
$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());
开发者ID:roy13,项目名称:EMON,代码行数:31,代码来源:feedwriter.php

示例4: llen

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

示例5: get

<?php

define('EMONCMS_EXEC', 1);
require "route.php";
$route = new Route(get('q'));
$redis = new Redis();
$redis->connect("127.0.0.1");
if ($route->format == 'json') {
    if ($route->controller == 'input') {
        if ($route->action == 'post') {
            $array = array("time" => time(), "apikey" => get('apikey'), "nodeid" => (int) get('node'), "csv" => get('csv'));
            $msg = json_encode($array);
            $buflength = $redis->llen('buffer');
            if ($buflength < 1000) {
                $redis->rpush('buffer', $msg);
            }
        }
    }
}
function get($index)
{
    $val = null;
    if (isset($_GET[$index])) {
        $val = $_GET[$index];
    }
    return $val;
}
开发者ID:jurviz,项目名称:development,代码行数:27,代码来源:very_lightweight_index.php

示例6: date

if (!$success) {
    error_log("\r\n track_log redis is fail", 3, '/tmp/err_track_log.log');
    echo "track_log redis is fail";
    exit;
}
if ($rpassword) {
    $redis_handle->auth($rpassword);
}
$redis_handle->select($rdb);
$redis_bi_key = 'bi';
while (true) {
    if ($to_exit) {
        echo "[" . date('Y-m-d H:i:s') . "] track log quit for user end\n";
        break;
    }
    if ($redis_handle->llen($redis_bi_key) > 0) {
        $url = $redis_handle->rpop($redis_bi_key);
        if (!empty($url)) {
            $result = curl($url);
            if ($result === false) {
                $redis_handle->lpush($redis_bi_key, $url);
            }
        }
    }
    //usleep(100000);
    usleep(1);
}
/**
 *
 * @param string $url
 * @param array $post_data
开发者ID:cfhb,项目名称:script,代码行数:31,代码来源:track_log.php

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

示例8: User

$redis->connect("127.0.0.1");
require "Modules/user/user_model.php";
$user = new User($mysqli, $redis, null);
require "Modules/feed/feed_model.php";
$feed = new Feed($mysqli, $redis, $timestore_adminkey);
require "Modules/input/input_model.php";
$input = new Input($mysqli, $redis, $feed);
require "Modules/input/process_model.php";
$process = new Process($mysqli, $input, $feed);
$rn = 0;
$ltime = time();
$usleep = 100000;
while (true) {
    if (time() - $ltime >= 1) {
        $ltime = time();
        $buflength = $redis->llen('buffer');
        // A basic throthler to stop the script using up cpu when there is nothing to do.
        // Fine tune sleep
        if ($buflength < 2) {
            $usleep += 50;
        } else {
            $usleep -= 50;
        }
        // if there is a big buffer reduce sleep to zero to clear buffer.
        if ($buflength > 100) {
            $usleep = 0;
        }
        // if throughput is low then increase sleep significantly
        if ($rn == 0) {
            $usleep = 100000;
        }
开发者ID:jurviz,项目名称:development,代码行数:31,代码来源:input_queue_auth_in_publisher.php

示例9: Redis

<?php

/*
 * 生成新消息,放入主queue中
 */
include_once __DIR__ . '/config.php';
$redis = new Redis();
$redis->connect(REDIS_HOST, REDIS_PORT);
while (1) {
    echo "Primary: " . $redis->llen(PRIMARY_CHANNEL) . ' Secondary: ' . $redis->llen(SECONDARY_CHANNEL) . "\n";
    sleep(1);
}
开发者ID:filix,项目名称:sms_queue,代码行数:12,代码来源:info.php

示例10: make_toolbar

    public static function make_toolbar()
    {
        $content = '';
        $infowindows = '';
        ob_start();
        if (!empty(self::$links)) {
            echo '<ul class="panel links">';
            foreach (self::$links as $link) {
                echo '<li>' . $link['label'] . ': <a href="' . $link['url'] . '">' . $link['link_text'] . '</a></li>';
            }
            echo '</ul>';
        }
        $stats = \jmvc\Db::$stats;
        if (is_array($stats)) {
            $total = $stats['select'] + $stats['insert'] + $stats['update'] + $stats['delete'];
            echo '<div class="panel">
				<h3>Database Stats</h3>
				<table class="data">
					<tr>
						<td><strong>Total</strong></td>
						<td class="num"><strong>' . $total . '</strong></td>
					</tr>
					<tr>
						<td>Select</td>
						<td class="num">' . $stats['select'] . '</td>
					</tr>
					<tr>
						<td>Insert</td>
						<td class="num">' . $stats['insert'] . '</td>
					</tr>
					<tr>
						<td>Update</td>
						<td class="num">' . $stats['update'] . '</td>
					</tr>
					<tr>
						<td>Delete</td>
						<td class="num">' . $stats['delete'] . '</td>
					</tr>
				</table>';
            $queries = \jmvc\Db::$queries;
            if (is_array($queries) && !empty($queries)) {
                $rows = '';
                foreach ($queries as $query) {
                    $rows .= '<tr>
						<td class="num">' . round($query['time'] * 1000) . 'ms</td>
						<td>' . self::table_names($query['query']) . '
						</td>
						<td><a href="#" class="showquery">Show Query</a>
							<div class="query">' . nl2br($query['query']) . '</div></td>
					</tr>';
                }
                $infoWindows .= '<div id="jmvc-debug-dbqueries">
					<table class="data">
						' . $rows . '
					</table>
				</div>';
                echo '<a href="#" rel="jmvc-debug-dbqueries" class="jmvc-debug-infoWindowLink">Show DB Queries</a>';
            }
            echo '</div>';
        }
        $stats = \jmvc\classes\Cache_Interface::$stats;
        if (is_array($stats)) {
            echo '<div class="panel">
				<h3>Cache Stats</h3>
				<table class="data">
					<tr>
						<td>Hits</td>
						<td class="num">' . $stats['hits'] . '</td>
					</tr>
					<tr>
						<td>Misses</td>
						<td class="num">' . $stats['misses'] . '</td>
					</tr>
					<tr>
						<td>Writes</td>
						<td class="num">' . $stats['writes'] . '</td>
					</tr>
				</table>';
            if (!empty($stats['keys'])) {
                $rows = '';
                foreach ($stats['keys'] as $key) {
                    $rows .= '<tr>
						<td>' . $key[0] . '</td>
						<td>' . $key[1] . '</td>
					</tr>';
                }
                $infoWindows .= '<div id="jmvc-debug-cache-keys">
					<table class="data">
						' . $rows . '
					</table>
				</div>';
                echo '<a href="#" rel="jmvc-debug-cache-keys" class="jmvc-debug-infoWindowLink">Show Keys</a>';
            }
            echo '</div>';
        }
        if (isset($GLOBALS['_CONFIG']['redis'])) {
            $r = new \Redis();
            $r->connect($GLOBALS['_CONFIG']['redis']['host'], $GLOBALS['_CONFIG']['redis']['port']);
            $mail_count = $r->llen('jmvc:rmail');
            if (IS_PRODUCTION && $mail_count) {
//.........这里部分代码省略.........
开发者ID:jonthornton,项目名称:JMVC,代码行数:101,代码来源:debug.php

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

示例12: cartSetCount

 /**
  * 设置某个商品在购物车里的数量
  * 此项操作必须是购物车至少有一件的情况
  */
 public function cartSetCount()
 {
     if (Auth::check()) {
         $cartkey = Auth::user()->front_uid;
     } else {
         $cartkey = $this->getIP();
     }
     $key = 'laravel:user:' . $cartkey . ':cart';
     $good_id = Input::get('good_id');
     $shop_id = Input::get('shop_id');
     // 不用
     $count = Input::get('count');
     $ids = array_count_values(Redis::lrange($key, 1, -1));
     $num = $count - $ids[$good_id];
     if ($num > 0) {
         for ($i = $num; $i > 0; $i--) {
             Redis::rpush($key, $good_id);
         }
     } elseif ($num < 0) {
         Redis::lrem($key, $num, $good_id);
         if (Redis::llen($key) == 1) {
             Redis::del($key);
         }
     }
     // 相等就不作处理了s
     //var_dump(Redis::lrange($key, 0, -1));
     return Response::json(array('success' => 'true'));
 }
开发者ID:andycall,项目名称:haochigou,代码行数:32,代码来源:ShopController.php


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