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


PHP Client::rpush方法代码示例

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


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

示例1: publish

 /**
  * @param string $queue Name of the queue to receive the job
  * @param string $command FQCN for Command class to be executed by the job
  * @param array $options Options for the Command class instance
  */
 public function publish($queue, $command, array $options = [])
 {
     if (!is_subclass_of($command, CommandInterface::class)) {
         throw new \RuntimeException('Class does not implement CommandInterface: ' . $command);
     }
     $job = json_encode(['command' => $command, 'options' => $options]);
     $this->client->rpush($queue, $job);
 }
开发者ID:equip,项目名称:redis-queue,代码行数:13,代码来源:Publisher.php

示例2: append

 public function append(EventStream $events)
 {
     foreach ($events as $event) {
         $data = $this->serializer->serialize($event, 'json');
         $event = $this->serializer->serialize(['type' => get_class($event), 'created_on' => (new DateTimeImmutable('now', new DateTimeZone('UTC')))->getTimestamp(), 'data' => $data], 'json');
         $this->predis->rpush('events:' . $events->aggregateId(), $event);
         $this->predis->rpush('published_events', $event);
     }
 }
开发者ID:dddinphp,项目名称:last-wishes-gamify,代码行数:9,代码来源:RedisEventStore.php

示例3: put

 /**
  * @param string        $key
  * @param string        $value
  * @param QueuePriority $priority
  * @return bool
  */
 public function put($key, $value, QueuePriority $priority = null)
 {
     if (!$priority) {
         $priority = QueuePriority::PRIORITY_NORMAL;
     }
     if ($this->checkConnection()) {
         return $this->predis->rpush(self::QUEUE_PREFIX . ':' . $priority . ':' . $key, $value);
     }
     return false;
 }
开发者ID:gerifield,项目名称:little-red-queue,代码行数:16,代码来源:LittleRedQueue.php

示例4: initializeRedis

 /**
  * Make sure, the Redis keys exist.
  *
  * @return void
  */
 private function initializeRedis()
 {
     if ($this->initialized) {
         return;
     }
     $this->hash = substr(sha1(serialize($this->items)), 0, 8);
     $positionKey = $this->getKeyForCurrentPosition();
     $existing = !$this->redis->setnx($positionKey, count($this->items) - 1);
     if (!$existing && count($this->items)) {
         $listKey = $this->getKeyForItemList();
         $this->itemCount = $this->redis->rpush($listKey, $this->items);
     }
     $this->initialized = true;
 }
开发者ID:battlerattle,项目名称:shuffle-bag,代码行数:19,代码来源:RedisStorage.php

示例5: listen

 /**
  * Start the worker and wait for requests
  */
 public function listen()
 {
     $context = new \ZMQContext();
     $server = new \ZMQSocket($context, \ZMQ::SOCKET_PULL);
     $server->bind('tcp://127.0.0.1:' . ($this->defaultPort + $this->client->getId() - 1));
     $this->logger->info('Client worker ' . $this->client . ' is ready');
     while (true) {
         $request = $server->recv();
         $this->logger->debug('Client worker ' . $this->client . ' receiving request : ' . $request);
         // Check if the input is valid, ignore if wrong
         $request = json_decode($request, true);
         if (!$this->isValidInput($request)) {
             $this->logger->error('Client worker ' . $this->client . ' received an invalid input');
             continue;
         }
         try {
             // Call the right method in the client and push to redis the result
             $result = call_user_func_array(array($this->client, $request['command']), $request['parameters']);
         } catch (ClientNotReadyException $e) {
             $this->logger->warning('Client worker ' . $this->client . ' received a request (#' . $request['invokeId'] . ') whereas the client is not ready. This is normal in case of client reconnection process. Ignoring.');
             continue;
         }
         $key = $this->key . '.client.commands.' . $request['invokeId'];
         $this->redis->rpush($key, serialize($result));
         $this->redis->expire($key, $this->expire);
     }
 }
开发者ID:phxlol,项目名称:lol-php-api,代码行数:30,代码来源:ClientWorker.php

示例6: haveInRedis

 /**
  * Creates or modifies keys
  *
  * If $key already exists:
  *
  * - Strings: its value will be overwritten with $value
  * - Other types: $value items will be appended to its value
  *
  * Examples:
  *
  * ``` php
  * <?php
  * // Strings: $value must be a scalar
  * $I->haveInRedis('string', 'Obladi Oblada');
  *
  * // Lists: $value can be a scalar or an array
  * $I->haveInRedis('list', ['riri', 'fifi', 'loulou']);
  *
  * // Sets: $value can be a scalar or an array
  * $I->haveInRedis('set', ['riri', 'fifi', 'loulou']);
  *
  * // ZSets: $value must be an associative array with scores
  * $I->haveInRedis('set', ['riri' => 1, 'fifi' => 2, 'loulou' => 3]);
  *
  * // Hashes: $value must be an associative array
  * $I->haveInRedis('hash', ['obladi' => 'oblada']);
  * ```
  *
  * @param string $type  The type of the key
  * @param string $key   The key name
  * @param mixed  $value The value
  *
  * @throws ModuleException
  */
 public function haveInRedis($type, $key, $value)
 {
     switch (strtolower($type)) {
         case 'string':
             if (!is_scalar($value)) {
                 throw new ModuleException($this, 'If second argument of haveInRedis() method is "string", ' . 'third argument must be a scalar');
             }
             $this->driver->set($key, $value);
             break;
         case 'list':
             $this->driver->rpush($key, $value);
             break;
         case 'set':
             $this->driver->sadd($key, $value);
             break;
         case 'zset':
             if (!is_array($value)) {
                 throw new ModuleException($this, 'If second argument of haveInRedis() method is "zset", ' . 'third argument must be an (associative) array');
             }
             $this->driver->zadd($key, $value);
             break;
         case 'hash':
             if (!is_array($value)) {
                 throw new ModuleException($this, 'If second argument of haveInRedis() method is "hash", ' . 'third argument must be an array');
             }
             $this->driver->hmset($key, $value);
             break;
         default:
             throw new ModuleException($this, "Unknown type \"{$type}\" for key \"{$key}\". Allowed types are " . '"string", "list", "set", "zset", "hash"');
     }
 }
开发者ID:solutionDrive,项目名称:Codeception,代码行数:65,代码来源:Redis.php

示例7: release

 /**
  * @inheritdoc
  */
 public function release(array $message, $delay = 0)
 {
     if ($delay > 0) {
         $this->redis->zadd($message['queue'] . ':delayed', [$message['body'] => time() + $delay]);
     } else {
         $this->redis->rpush($message['queue'], [$message['body']]);
     }
 }
开发者ID:Nuffic,项目名称:yii2-queue-1,代码行数:11,代码来源:RedisQueue.php

示例8: addTask

 /**
  * @param Task $task
  * @return null
  */
 function addTask(Task $task)
 {
     $serialized = serialize($task);
     $existingStatus = $this->getStatus($task);
     if ($existingStatus) {
         //TODO - what should happen here?
         return null;
     }
     $taskKey = $task->getKey();
     $this->redisClient->set($taskKey, $serialized);
     $this->redisClient->rpush($this->announceListKey, $taskKey);
     $this->setStatus($taskKey, TaskQueue::STATE_INITIAL);
 }
开发者ID:sdmmember,项目名称:Imagick-demos,代码行数:17,代码来源:RedisTaskQueue.php

示例9: addTask

 /**
  * @param Task $task
  * @return null
  */
 public function addTask(Task $task)
 {
     $taskKey = $task->getKey();
     $taskSpecificKey = $this->taskListKey . $taskKey;
     $serialized = serialize($task);
     $existingStatus = $this->getStatus($task);
     if ($existingStatus) {
         //TODO - what should happen here?
         return $taskSpecificKey;
     }
     $this->redisClient->set($taskSpecificKey, $serialized, 'EX', self::TASK_TTL);
     $this->redisClient->rpush($this->announceListKey, $taskKey);
     $this->setStatus($task, TaskQueue::STATE_INITIAL);
     return true;
 }
开发者ID:atawsports2,项目名称:Imagick-demos,代码行数:19,代码来源:RedisTaskQueue.php

示例10: put

 /**
  * @param string $queueName
  * @param mixed $workload
  */
 public function put($queueName, $workload)
 {
     $this->predis->rpush($queueName, serialize($workload));
 }
开发者ID:acassan,项目名称:worker-bundle,代码行数:8,代码来源:PRedis.php

示例11: write

 /**
  * @param array $record
  */
 protected function write(array $record)
 {
     $this->redisClient->rpush($this->redisKey, sprintf('%s|%s', $record['level'], $record['message']));
 }
开发者ID:phxlol,项目名称:lol-php-api,代码行数:7,代码来源:RedisHandler.php

示例12: writeCommandReply

 /**
  * @param string $commandIdentifier
  * @param mixed $reply
  */
 public function writeCommandReply($commandIdentifier, $reply)
 {
     $this->client->rpush(sprintf(self::COMMAND_RESPONSE_KEY, $commandIdentifier), [$reply]);
     $this->client->expire(sprintf(self::COMMAND_RESPONSE_KEY, $commandIdentifier), $this->timeout);
 }
开发者ID:fcm,项目名称:GovernorFramework,代码行数:9,代码来源:RedisTemplate.php

示例13: setList

 /**
  * 设置列表数据
  * @param string $key
  * @param array $elements
  * @return int
  */
 public function setList($key, $elements)
 {
     // list:magazine:100:images 12 13 14
     return $this->redis->rpush($key, (array) $elements);
 }
开发者ID:inhere,项目名称:php-librarys,代码行数:11,代码来源:Redis.php

示例14: recordGauge

 public function recordGauge($name, $value, $measureTime = null)
 {
     $counter = new \Stats\Gauge($name, $value, $this->sourceName, $measureTime);
     $serialized = serialize($counter);
     $this->redisClient->rpush($this->getGaugeKey(), [$serialized]);
 }
开发者ID:atawsports2,项目名称:Imagick-demos,代码行数:6,代码来源:AsyncStats.php

示例15: sendMessage

 public function sendMessage($messageBody, $queueId = null)
 {
     $queueId = $this->normaliseQueueId($queueId);
     $this->predis->rpush($queueId, [$messageBody]);
 }
开发者ID:silktide,项目名称:queueball-redis,代码行数:5,代码来源:Queue.php


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