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


PHP Redis::lPush方法代码示例

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


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

示例1: push

 public static function push($key, $value)
 {
     $redis = self::instance();
     if ($redis) {
         self::$redis->lPush($key, $value);
     }
 }
开发者ID:aoyel,项目名称:pinst,代码行数:7,代码来源:RedisQuery.php

示例2: put

 /**
  * put value into the queue
  *
  * @param $value
  * @return bool
  */
 public function put($value)
 {
     if ($this->redis->lPush($this->channel, $value) !== false) {
         return true;
     }
     return false;
 }
开发者ID:huyanping,项目名称:simple-fork-php,代码行数:13,代码来源:RedisQueue.php

示例3: lPush

 /**
  * Prepend a value to a list
  *
  * @param string $key
  * @param string $value
  * @throws CM_Exception_Invalid
  */
 public function lPush($key, $value)
 {
     $length = $this->_redis->lPush($key, $value);
     if (false === $length) {
         throw new CM_Exception_Invalid('Cannot push to list `' . $key . '`.');
     }
 }
开发者ID:aladin1394,项目名称:CM,代码行数:14,代码来源:Client.php

示例4: pushMulti

 /**
  * 将批量数据加入队列开头
  * @注意:当加入的数据量较大,比如超过10KB时,建议使用pipeline方式
  * @注意:当提交的数据条数较多时,$pipeline为FALSE效率更高
  * @param array $arrValues array('v1','v2') 按照数组的顺序,第一个元素将首先被加入队列,最后一个元素将最后加入队列
  * @param bool $pipeline 默认为FALSE。当为TRUE时,通过PIPELINE的模式提交,为FALSE时,通过原生的方式提交。
  * @return long 成功返回TRUE(可能是0),失败时返回FALSE
  */
 public function pushMulti($arrValues, $pipeline = FALSE)
 {
     if ($pipeline) {
         if (!$this->rd->isConnected()) {
             if (!$this->reconnRedis()) {
                 return FALSE;
             }
         }
         $this->rd->multi(\Redis::PIPELINE);
         foreach ($arrValues as $v) {
             $this->rd->lPush($this->k, $v);
         }
         $re = $this->rd->exec();
         return TRUE;
     } else {
         array_unshift($arrValues, $this->k);
         try {
             return call_user_func_array(array($this->rd, 'lPush'), $arrValues);
         } catch (\RedisException $e) {
             if ($this->reconnRedis()) {
                 return call_user_func_array(array($this->rd, 'lPush'), $arrValues);
             }
         }
     }
     return FALSE;
 }
开发者ID:seepre,项目名称:api.seepre.com,代码行数:34,代码来源:RedQueue.php

示例5: abort

 /**
  * @inheritdoc
  */
 public function abort($messageId)
 {
     $this->checkClientConnection();
     $numberOfRemoved = $this->client->lRem("queue:{$this->name}:processing", $messageId, 0);
     if ($numberOfRemoved === 1) {
         $this->client->lPush("queue:{$this->name}:failed", $messageId);
     }
 }
开发者ID:flowpack,项目名称:jobqueue-redis,代码行数:11,代码来源:RedisQueue.php

示例6: testlGet

 public function testlGet()
 {
     $this->redis->delete('list');
     $this->redis->lPush('list', 'val');
     $this->redis->lPush('list', 'val2');
     $this->redis->lPush('list', 'val3');
     $this->assertEquals('val', $this->redis->lGet('list', 0));
     $this->assertEquals('val2', $this->redis->lGet('list', 1));
     $this->assertEquals('val3', $this->redis->lGet('list', 2));
     $this->redis->lPush('list', 'val4');
     $this->assertEquals('val4', $this->redis->lGet('list', 3));
 }
开发者ID:hieutrieu,项目名称:phpredis,代码行数:12,代码来源:TestRedis.php

示例7: queue_task

/**
 * Queue a task to be run by Celery.
 *
 * @param task Celery task name.
 * @param args (Optional) array of arguments.
 * @param kwargs (Optional) hash of keyword arguments.
 */
function queue_task($task, $args = null, $kwargs = null)
{
    // assemble Celery-ready messages
    $body = array("id" => uniqid(CELERY_ID_PREFIX), "task" => $task);
    if (!empty($args)) {
        $body["args"] = $args;
    }
    if (!empty($kwargs)) {
        $body["kwargs"] = $kwargs;
    }
    $envelope = array("content-encoding" => "utf-8", "content-type" => "application/json", "body" => base64_encode(json_encode($body)), "properties" => array("body_encoding" => "base64", "delivery_tag" => uniqid(CELERY_ID_PREFIX), "delivery_mode" => 2, "delivery_info" => array("exchange" => CELERY_REDIS_KEY, "routing_key" => CELERY_REDIS_KEY, "priority" => 0)));
    $redis = new Redis();
    $redis->connect(REDIS_HOST);
    $redis->lPush(CELERY_REDIS_KEY, json_encode($envelope));
    $redis->close();
}
开发者ID:ndpgroup,项目名称:fp-legacy,代码行数:23,代码来源:lib.queue.php

示例8: putOutput

 /**
  * @param string $type
  * @param InputMessageIdentifier $identifier
  * @param OutputMessage $outputMessage
  */
 public function putOutput($type, InputMessageIdentifier $identifier, OutputMessage $outputMessage)
 {
     $messageId = $identifier->getId();
     $captureResult = 'MessageNotFinished' === $this->redis->hGet($this->getMessageResultKey($type), $messageId);
     $this->redis->multi();
     $this->redis->lRem($this->getMessageRunKey($type), $messageId, 0);
     $this->redis->hDel($this->getMessageStartTimeKey($type), $messageId);
     $this->redis->lRem($this->getMessageQueueKey($type), $messageId, 0);
     $this->redis->hDel($this->getMessageQueueTimeKey($type), $messageId);
     $this->redis->hDel($this->getMessageKey($type), $messageId);
     if ($captureResult) {
         $data = $outputMessage->getData();
         $this->redis->hSet($this->getMessageResultKey($type), $messageId, $data);
         $this->redis->lPush($this->getMessageResultReadyKey($type, $messageId), 'true');
     }
     $this->redis->exec();
 }
开发者ID:parallel-php,项目名称:parallel-task,代码行数:22,代码来源:RedisQueue.php

示例9: end

 public function end($task)
 {
     $taskId = $task->getId();
     $captureResult = 'TaskNotFinished' === $this->redis->hGet($this->getTaskResultKey(), $taskId);
     $this->redis->multi();
     $this->redis->lRem($this->getTaskRunKey(), $taskId, 0);
     $this->redis->hDel($this->getTaskStartTimeKey(), $taskId);
     $this->redis->lRem($this->getTaskQueueKey(), $taskId, 0);
     $this->redis->hDel($this->getTaskQueueTimeKey(), $taskId);
     $this->redis->hDel($this->getTaskKey(), $taskId);
     if ($captureResult) {
         $taskResult = $task->getResult();
         $serializedTaskResult = serialize($taskResult);
         $this->redis->hSet($this->getTaskResultKey(), $taskId, $serializedTaskResult);
         $this->redis->lPush($this->getTaskResultReadyKey($taskId), 'true');
     }
     $this->redis->exec();
 }
开发者ID:drealecs,项目名称:thread-worker,代码行数:18,代码来源:RedisQueue.php

示例10: testlGetRange

 public function testlGetRange()
 {
     $this->redis->delete('list');
     $this->redis->lPush('list', 'val');
     $this->redis->lPush('list', 'val2');
     $this->redis->lPush('list', 'val3');
     // pos :   0     1     2
     // pos :  -3    -2    -1
     // list: [val3, val2, val]
     $this->assertEquals($this->redis->lGetRange('list', 0, 0), array('val3'));
     $this->assertEquals($this->redis->lGetRange('list', 0, 1), array('val3', 'val2'));
     $this->assertEquals($this->redis->lGetRange('list', 0, 2), array('val3', 'val2', 'val'));
     $this->assertEquals($this->redis->lGetRange('list', 0, 3), array('val3', 'val2', 'val'));
     $this->assertEquals($this->redis->lGetRange('list', 0, -1), array('val3', 'val2', 'val'));
     $this->assertEquals($this->redis->lGetRange('list', 0, -2), array('val3', 'val2'));
     $this->assertEquals($this->redis->lGetRange('list', -2, -1), array('val2', 'val'));
     $this->redis->delete('list');
     $this->assertEquals($this->redis->lGetRange('list', 0, -1), array());
 }
开发者ID:virtulis,项目名称:phpredis,代码行数:19,代码来源:TestRedis.php

示例11: listPush

 /**
  * 入队列
  * @param $list string 队列名
  * @param $value mixed 入队元素值
  * @param $deriction int 0:数据入队列头(左) 1:数据入队列尾(右) 默认为0
  * @param $repeat int 判断value是否存在  0:不判断存在 1:判断存在 如果value存在则不入队列
  */
 public static function listPush($list, $value, $direction = 0, $repeat = 0)
 {
     $redis = new \Redis();
     $redis->connect(self::_HOST, self::_PORT);
     $return = null;
     switch ($direction) {
         case 0:
             if ($repeat) {
                 $return = $redis->lPushx($list, $value);
             } else {
                 $return = $redis->lPush($list, $value);
             }
             break;
         case 1:
             if ($repeat) {
                 $return = $redis->rPushx($list, $value);
             } else {
                 $return = $redis->rPush($list, $value);
             }
             break;
         default:
             $return = false;
             break;
     }
     $redis->close();
     $redis = null;
     return $return;
 }
开发者ID:skyshow,项目名称:ticket,代码行数:35,代码来源:MyRedis.class.php

示例12: foreach

    $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');
        //shell_exec('sudo /home/william/Git/weike/hook/pull.sh');
    }
}
/*
* contents of pull.sh
*
* #!/bin/sh
* # sudo -Hu www-data pwd && cd /home/william/Git/weike && /usr/bin/git pull >>/home/william/Git/weike/hook/pull.log 2>&1
* cd /home/william/workspace/PHP/wapacom
* /usr/bin/sudo -Hu www-data /usr/bin/git pull >>/home/william/workspace/PHP/wapacom/hook/pull.log 2>&1
*/
开发者ID:pengweifu,项目名称:myConfigFiles,代码行数:31,代码来源:gitAutoUpdate.php

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

示例14: lpush

 public function lpush($key, $value)
 {
     return $this->client->lPush($key, $value);
 }
开发者ID:yoye,项目名称:redis-broker,代码行数:4,代码来源:PhpRedisAdapter.php

示例15: put

 /**
  * put value into the queue of channel
  * @param $channel
  * @param $value
  * @return mixed
  */
 public function put($channel, $value)
 {
     return $this->redis->lPush($channel, $value);
 }
开发者ID:jzxyouok,项目名称:simple-fork-php,代码行数:10,代码来源:RedisQueue.php


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