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


PHP Redis::lRange方法代码示例

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


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

示例1: requeueOldWorkingTasks

 private function requeueOldWorkingTasks()
 {
     $taskIds = array_unique($this->redis->lRange($this->getTaskRunKey(), 0, -1));
     foreach ($taskIds as $taskId) {
         $time = $this->redis->hGet($this->getTaskStartTimeKey(), $taskId);
         if (!empty($time) && time() > $this->taskTimeout + (int) $time) {
             $this->redis->multi();
             $this->redis->rPush($this->getTaskQueueKey(), $taskId);
             $this->redis->lRem($this->getTaskRunKey(), $taskId, 1);
             $this->redis->hDel($this->getTaskStartTimeKey(), $taskId);
         }
     }
 }
开发者ID:drealecs,项目名称:thread-worker,代码行数:13,代码来源:RedisQueue.php

示例2: lRange

 /**
  * Return values from list
  *
  * @param string   $key
  * @param int|null $start
  * @param int|null $stop
  * @return array
  */
 public function lRange($key, $start = null, $stop = null)
 {
     if (null === $start) {
         $start = 0;
     }
     if (null === $stop) {
         $stop = -1;
     }
     return $this->_redis->lRange($key, $start, $stop);
 }
开发者ID:aladin1394,项目名称:CM,代码行数:18,代码来源:Client.php

示例3: Redis

 static function through_area_get_school($area)
 {
     $redis = new Redis();
     $redis->connect('127.0.0.1', 6379);
     $list = $redis->lRange($area, 0, 500);
     if (empty($list)) {
         $local = new medoo();
         $list = $local->select('school', 'name', array('area' => $area));
         unset($local);
     }
     unset($redis);
     return $list;
 }
开发者ID:keensting,项目名称:ErhuoAmbass,代码行数:13,代码来源:school_handler.php

示例4: peek

 /**
  * @inheritdoc
  */
 public function peek($limit = 1)
 {
     $this->checkClientConnection();
     $result = $this->client->lRange("queue:{$this->name}:messages", -$limit, -1);
     if (!is_array($result) || count($result) === 0) {
         return [];
     }
     $messages = [];
     foreach ($result as $messageId) {
         $encodedPayload = $this->client->hGet("queue:{$this->name}:ids", $messageId);
         $messages[] = new Message($messageId, json_decode($encodedPayload, true));
     }
     return $messages;
 }
开发者ID:flowpack,项目名称:jobqueue-redis,代码行数:17,代码来源:RedisQueue.php

示例5: requeueOldWorkingMessages

 private function requeueOldWorkingMessages($type)
 {
     $messageIds = array_unique($this->redis->lRange($this->getMessageRunKey($type), 0, -1));
     foreach ($messageIds as $messageId) {
         $time = $this->redis->hGet($this->getMessageStartTimeKey($type), $messageId);
         if (!empty($time) && time() > $this->messageTimeout + (int) $time) {
             $this->redis->multi();
             $this->redis->rPush($this->getMessageQueueKey($type), $messageId);
             $this->redis->lRem($this->getMessageRunKey($type), $messageId, 1);
             $this->redis->hDel($this->getMessageStartTimeKey($type), $messageId);
             $this->redis->exec();
         }
     }
 }
开发者ID:parallel-php,项目名称:parallel-task,代码行数:14,代码来源:RedisQueue.php

示例6: freeze

 /**
  * Freezes this cache backend.
  *
  * All data in a frozen backend remains unchanged and methods which try to add
  * or modify data result in an exception thrown. Possible expiry times of
  * individual cache entries are ignored.
  *
  * A frozen backend can only be thawn by calling the flush() method.
  *
  * @throws \RuntimeException
  * @return void
  */
 public function freeze()
 {
     if ($this->isFrozen()) {
         throw new \RuntimeException(sprintf('Cannot add or modify cache entry because the backend of cache "%s" is frozen.', $this->cacheIdentifier), 1323344192);
     }
     do {
         $entriesKey = $this->buildKey('entries');
         $this->redis->watch($entriesKey);
         $entries = $this->redis->lRange($entriesKey, 0, -1);
         $this->redis->multi();
         foreach ($entries as $entryIdentifier) {
             $this->redis->persist($this->buildKey('entry:' . $entryIdentifier));
         }
         $this->redis->set($this->buildKey('frozen'), 1);
         $result = $this->redis->exec();
     } while ($result === false);
     $this->frozen = true;
 }
开发者ID:mkeitsch,项目名称:flow-development-collection,代码行数:30,代码来源:RedisBackend.php

示例7: view

 public function view()
 {
     $key = isset($_GET['key']) ? $_GET['key'] : '';
     $pageId = isset($_GET['page']) ? max(intval($_GET['page']), 1) : 1;
     if (empty($key)) {
         Message::showError('项目key不能为空');
     }
     $limit = 50;
     $host = '172.16.53.68';
     $port = 6381;
     $rd = new Redis();
     $rd->connect($host, $port);
     $count = $rd->lsize($key);
     $data = $rd->lRange($key, $limit * ($pageId - 1), $limit * $pageId);
     $data = array_map('unserialize', $data);
     Common::debug($data);
     // $data = unserialize($data);
     // Common::debug($data);exit;
     $pageModel = new Page($count, $limit);
     $this->setView('data', $data);
     $this->setView('pageStr', $pageModel->getPageStr());
     $this->display('XhprofLog.html');
 }
开发者ID:sdgdsffdsfff,项目名称:dagger_alarm,代码行数:23,代码来源:XhprofLogController.php

示例8: testRenameNx

 public function testRenameNx()
 {
     // strings
     $this->redis->del('{key}0', '{key}1');
     $this->redis->set('{key}0', 'val0');
     $this->redis->set('{key}1', 'val1');
     $this->assertTrue($this->redis->renameNx('{key}0', '{key}1') === FALSE);
     $this->assertTrue($this->redis->get('{key}0') === 'val0');
     $this->assertTrue($this->redis->get('{key}1') === 'val1');
     // lists
     $this->redis->del('{key}0');
     $this->redis->del('{key}1');
     $this->redis->lPush('{key}0', 'val0');
     $this->redis->lPush('{key}0', 'val1');
     $this->redis->lPush('{key}1', 'val1-0');
     $this->redis->lPush('{key}1', 'val1-1');
     $this->assertTrue($this->redis->renameNx('{key}0', '{key}1') === FALSE);
     $this->assertTrue($this->redis->lRange('{key}0', 0, -1) === array('val1', 'val0'));
     $this->assertTrue($this->redis->lRange('{key}1', 0, -1) === array('val1-1', 'val1-0'));
     $this->redis->del('{key}2');
     $this->assertTrue($this->redis->renameNx('{key}0', '{key}2') === TRUE);
     $this->assertTrue($this->redis->lRange('{key}0', 0, -1) === array());
     $this->assertTrue($this->redis->lRange('{key}2', 0, -1) === array('val1', 'val0'));
 }
开发者ID:Jerry-Shaw,项目名称:phpredis,代码行数:24,代码来源:RedisTest.php

示例9: array

?>
<div align="center" style="width: 100%">
<h2>Programmazione settimanale</h2>
<form name=uno action=salva_prog.php method=post>
<table border=2 cellpadding=0 cellspacing=0 width=100%>
<tr><td></td>
<?php 
$giorni = array("vuoto", "lun", "mar", "mer", "gio", "ven", "sab", "dom");
for ($ora = 0; $ora <= 23; $ora++) {
    echo '<th width="4%">' . $ora . ' </th>';
}
?>
</tr>
<?php 
for ($giorno = 1; $giorno <= 7; $giorno++) {
    $prog_giorno = $redis->lRange($giorni[$giorno], -24, -1);
    //print_r($prog_giorno);
    ?>
    <tr>
        <td width="4%"><?php 
    echo $giorni[$giorno];
    ?>
</td>
        <?php 
    for ($ora = 0; $ora <= 23; $ora++) {
        ?>
            <td class=compatta>
                <select name="<?php 
        echo $giorno;
        ?>
_<?php 
开发者ID:absinth84,项目名称:RaspCaldaia,代码行数:31,代码来源:prog_settimana.php

示例10: Redis

<?php

error_reporting(E_ALL);
ini_set('display_errors', 'On');
$method = $_SERVER['REQUEST_METHOD'];
parse_str(file_get_contents('php://input'), $data);
$data = array_merge($_GET, $_POST, $data);
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
if (empty($data)) {
    $data = $redis->lRange('commit', 0, -1);
    $html = '<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>Commit Lists</title></head><body><link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css"><script src="http://cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script><script src="http://cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.min.js"></script><div class="container-fluid"><div class="table-responsive"><table class="table table-striped"><thead><tr><th>#</th><th>Author</th><th>Email</th><th>Branch</th><th>Time</th><th>Description</th></tr></thead><tbody>';
    if ($data) {
        foreach ($data as $key => $value) {
            $value = json_decode($value, 1);
            $html .= '<tr>';
            $html .= '<td>' . $key . '</td>';
            isset($value['author']) && ($html .= '<td>' . $value['author'] . '</td>');
            isset($value['mail']) && ($html .= '<td>' . $value['mail'] . '</td>');
            isset($value['branch']) && ($html .= '<td>' . $value['branch'] . '</td>');
            isset($value['time']) && ($html .= '<td>' . $value['time'] . '</td>');
            isset($value['description']) && ($html .= '<td>' . $value['description'] . '</td>');
            $html .= '</tr>';
        }
    }
    $html .= '</tbody></table></div></div></body></html>';
    echo $html;
} else {
    $redis->lPush('commit', json_encode($data));
    if ($data['branch'] == 'master') {
        shell_exec('sudo ./pull.sh');
开发者ID:pengweifu,项目名称:myConfigFiles,代码行数:31,代码来源:gitAutoUpdate.php

示例11: notify

<?php

/*
$con = mysql_connect('localhost','root','abc123');
$db = mysql_select_db('test');


$q = "INSERT INTO notify ('user_id','msg') values ($user_id,$msg)";

mysql_query($q);
*/
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
echo $redis->ping();
$redis->lPush("key1e", 1, 2, 3, 4);
var_dump($redis->lRange('key1e', 0, -1));
$key = "Key_Name";
$redis->set($key, 'Key Value');
echo $redis->get($key);
//echo $_POST['time'];
开发者ID:prabhatse,项目名称:olx_hack,代码行数:20,代码来源:chat.php

示例12: listGet

 /**
  * 获取list队列的index位置的元素值
  * @param $list string 队列名
  * @param $index int 队列元素开始位置 默认0
  * @param $end int 队列元素结束位置 $index=0,$end=-1:返回队列所有元素
  */
 public static function listGet($list, $index = 0, $end = null)
 {
     $redis = new \Redis();
     $redis->connect(self::_HOST, self::_PORT);
     $return = null;
     if ($end) {
         $return = $redis->lRange($list, $index, $end);
     } else {
         $return = $redis->lGet($list, $index);
     }
     $redis->close();
     $redis = null;
     return $return;
 }
开发者ID:skyshow,项目名称:ticket,代码行数:20,代码来源:MyRedis.class.php

示例13: rand

// 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;
$bool = $redis->sMove("myset", "myset1", 35);
echo $bool;
$data = $redis->smembers("myset");
$bool = $redis->sismember("myset", 555);
开发者ID:isS,项目名称:NoSQL,代码行数:31,代码来源:redisWithPHP.php

示例14: Redis

	var data = [], datarelay = [], dataest = [], options;

	<?php 
//if (!$_REQUEST['start'] && !$_REQUEST['end']) {
$start = -300;
$end = -1;
//} else {
//	$start=$_REQUEST['start'];
//	$end=$_REQUEST['end'];
//}
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
$redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_NONE);
//$count = $redis->dbSize();
$lettura = $redis->lRange('lettura', $start, $end);
$timestamp = $redis->lRange('timestamp', $start, $end);
$temp_esterna = $redis->lRange('temp_esterna', $start, $end);
$termo = $redis->lRange('camera', $start, $end);
$rele = $redis->lRange('rele', $start, $end);
//$temp_1       = $redis->lRange('temp_1', $start, $end);
//$temp_2       = $redis->lRange('temp_2', $start, $end);
//$temp_3       = $redis->lRange('temp_3', $start, $end);
$min = $redis->lRange('min', $start, $end);
$max = $redis->lRange('max', $start, $end);
for ($x = 0; $x <= abs($start) - 1; $x++) {
    echo "data.push([" . $timestamp[$x] . ", " . $termo[$x] . "]);\n";
    echo "datarelay.push([" . $timestamp[$x] . ", " . $rele[$x] * 10 . "]);\n";
    echo "dataest.push([" . $timestamp[$x] . ", " . $temp_esterna[$x] . "]);\n";
    //echo "d1.push([" . $timestamp[$x] . "," . ($termo[$x]+10) . "]);\t";
    //echo "d2.push([" . $timestamp[$x] . "," . (($min[$x]+$max[$x])/2) . "]);\n";
开发者ID:absinth84,项目名称:RaspCaldaia,代码行数:30,代码来源:termo.php


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