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


PHP Client::lpush方法代码示例

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


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

示例1: returnMessage

 public function returnMessage(QueueMessage $message)
 {
     // re-add the message to the queue, as the first element
     $this->predis->lpush($message->getQueueId(), $message->getMessage());
     // forget we received the message
     $this->completeMessage($message);
 }
开发者ID:silktide,项目名称:queueball-redis,代码行数:7,代码来源:Queue.php

示例2: addMessage

 /**
  * @param Message $message
  */
 public function addMessage(Message $message)
 {
     /**
      * @todo 
      * add message to channel 
      */
     $this->client->lpush($this->getName(), $message->getAsString());
 }
开发者ID:slaszu,项目名称:redismq,代码行数:11,代码来源:Queue.php

示例3: submit

 /**
  * Publish a message to the queue
  *
  * @param \Flowpack\JobQueue\Common\Queue\Message $message
  * @return void
  */
 public function submit(\Flowpack\JobQueue\Common\Queue\Message $message)
 {
     if ($message->getIdentifier() !== NULL) {
         $added = $this->client->sadd("queue:{$this->name}:ids", $message->getIdentifier());
         if (!$added) {
             return;
         }
     }
     $encodedMessage = $this->encodeMessage($message);
     $this->client->lpush("queue:{$this->name}:messages", $encodedMessage);
     $message->setState(\Flowpack\JobQueue\Common\Queue\Message::STATE_SUBMITTED);
 }
开发者ID:admaykin,项目名称:Admaykin.Jobqueue.Redis,代码行数:18,代码来源:RedisQueue.php

示例4: handle

 /**
  * @param EventInterface $event
  */
 public function handle(EventInterface $event)
 {
     $this->redis->lpush(self::BUFFER_LIST_KEY, json_encode($event->toArray()));
     if ($this->redis->exists(self::BUFFER_TIMER_KEY)) {
         $this->redis->pexpire(self::BUFFER_TIMER_KEY, self::BUFFER_TIMEOUT_MILLISECONDS);
     } else {
         $this->redis->psetex(self::BUFFER_TIMER_KEY, self::BUFFER_TIMEOUT_MILLISECONDS, '1');
         while ($this->redis->exists(self::BUFFER_TIMER_KEY)) {
             usleep(self::BUFFER_SLEEP_MILLISECONDS);
         }
         $this->handleBufferedEvents();
     }
 }
开发者ID:akentner,项目名称:incoming-ftp,代码行数:16,代码来源:HostSendertoolOnlineStateChanged.php

示例5: tweet

 /**
  * @param string $status
  */
 public function tweet($status)
 {
     $postId = $this->redisClient->incr("global:nextPostId");
     $userId = $this->session->get('userId');
     $post = $userId . "|" . (new \DateTime())->format('d/m/y') . "|" . $status;
     $this->redisClient->set("post:{$postId}", $post);
     $followers = $this->redisClient->smembers("uid:" . $userId . ":followers");
     if ($followers === false) {
         $followers = [];
     }
     $followers[] = $userId;
     foreach ($followers as $fid) {
         $this->redisClient->lpush("uid:{$fid}:posts", [$postId]);
     }
     $this->redisClient->lpush("global:timeline", [$postId]);
     $this->redisClient->ltrim("global:timeline", 0, 1000);
 }
开发者ID:KrunoKnego,项目名称:Symfony-Twitter-Clone,代码行数:20,代码来源:RedisTweet.php

示例6: storeAssociation

 /**
  * Store association until its expiration time in Redis server. 
  * Overwrites any existing association with same server_url and 
  * handle. Handles list of associations for every server. 
  */
 function storeAssociation($server_url, $association)
 {
     // create Redis keys for association itself
     // and list of associations for this server
     $associationKey = $this->associationKey($server_url, $association->handle);
     $serverKey = $this->associationServerKey($server_url);
     // save association to server's associations' keys list
     $this->redis->lpush($serverKey, $associationKey);
     // Will touch the association list expiration, to avoid filling up
     $newExpiration = $association->issued + $association->lifetime;
     $expirationKey = $serverKey . '_expires_at';
     $expiration = $this->redis->get($expirationKey);
     if (!$expiration || $newExpiration > $expiration) {
         $this->redis->set($expirationKey, $newExpiration);
         $this->redis->expireat($serverKey, $newExpiration);
         $this->redis->expireat($expirationKey, $newExpiration);
     }
     // save association itself, will automatically expire
     $this->redis->setex($associationKey, $newExpiration - time(), serialize($association));
 }
开发者ID:Stony-Brook-University,项目名称:doitsbu,代码行数:25,代码来源:PredisStore.php

示例7: atomicPush

 /**
  * Push job to redis
  *
  * @param string     $jobId
  * @param string     $class
  * @param array      $args
  * @param string     $queue
  * @param bool       $retry
  * @param float|null $doAt
  * @throws exception Exception
  */
 private function atomicPush($jobId, $class, $args = [], $queue = self::QUEUE, $retry = true, $doAt = null)
 {
     if (array_values($args) !== $args) {
         throw new Exception('Associative arrays in job args are not allowed');
     }
     if (!is_null($doAt) && !is_float($doAt) && is_string($doAt)) {
         throw new Exception('at argument needs to be in a unix epoch format. Use microtime(true).');
     }
     $job = $this->serializer->serialize($jobId, $class, $args, $retry);
     if ($doAt === null) {
         $this->redis->sadd($this->name('queues'), $queue);
         $this->redis->lpush($this->name('queue', $queue), $job);
     } else {
         $this->redis->zadd($this->name('schedule'), [$job => $doAt]);
     }
 }
开发者ID:spinx,项目名称:sidekiq-job-php,代码行数:27,代码来源:Client.php

示例8: Job_Lookup_Word

 public function Job_Lookup_Word()
 {
     $word = $this->job_details->word;
     $this->status = 'working';
     $this->Report();
     try {
         $url = 'http://www.dictionaryapi.com/api/v1/references/collegiate/xml/' . urlencode($word) . '?key=' . DICTIONARY_API_KEY;
         $contents = @file_get_contents($url);
         /*
          * I really don't know how to manipulate very complex XML easily in PHP,
          * so please ignore the hideous hacks that you are about to see.
          */
         $xml = new SimpleXMLElement($contents);
         $results = $xml->xpath('/entry_list/entry[1]//dt');
         $return = '';
         foreach ($results as $node) {
             /* @var $node SimpleXMLElement */
             $string = $node->asXML();
             // Please ignore the developer behind the curtain
             $string = str_replace('<dt>:', '', $string);
             $string = str_replace(':</dt>', '', $string);
             $def = trim(strip_tags($string));
             // Return the longest definition
             if (strlen($def) > strlen($return)) {
                 $return = $def;
             }
         }
     } catch (Exception $ex) {
         $def = "{$word} failed: " . $ex->getMessage();
     }
     // Okay, you can start paying attention again now.
     $json = json_encode(array('word' => $word, 'def' => $def));
     $this->last_word = $word;
     $this->last_def = $def;
     echo "\n {$word}: {$return} \n";
     $this->redis->lpush('word.defs', $json);
     $this->redis->ltrim('word.defs', 0, 20);
     $this->beanstalk->delete($this->job);
     // Wait 2 seconds so we don't overload the API
     usleep(2000000);
 }
开发者ID:Grosloup,项目名称:PHP-Workers-Tutorial,代码行数:41,代码来源:worker.php

示例9: lpushUnorderedList

 /**
  * Utility method to to an LPUSH of some unordered values on a key.
  *
  * @param Client $redis Redis client instance.
  * @param string $key   Target key
  *
  * @return array
  */
 protected function lpushUnorderedList(Client $redis, $key)
 {
     $list = array(2, 100, 3, 1, 30, 10);
     $redis->lpush($key, $list);
     return $list;
 }
开发者ID:pikniktech,项目名称:dailybriefweb2,代码行数:14,代码来源:KeySortTest.php

示例10: putFirst

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

示例11: listSave

 private function listSave()
 {
     return $this->client->lpush($this->key_header, array($this->message->getJsonFormat()));
 }
开发者ID:nyogjtrc,项目名称:notify-postman,代码行数:4,代码来源:NotifyRedisHandler.php

示例12: put

 public function put($job)
 {
     $job['id'] = $this->redis->incr("job_id");
     $this->redis->lpush("jobs", serialize($job));
     return $job['id'];
 }
开发者ID:ekowabaka,项目名称:ajumamoro,代码行数:6,代码来源:RedisBroker.php

示例13: count

    $winners = $app['random']->getRandomNumbers(0, count($checkins) - 1);
    return $app['twig']->render('event.html.twig', array('event' => $event, 'winners' => $winners, 'checkins' => $checkins));
})->bind('event');
// Check-in page for Event
$app->get('/event/{id}/checkin', function ($id, Request $request) use($app) {
    $event = $app['meetup']->getEvent($id);
    $client = new Client();
    $checkins = array_filter($client->lrange('checkin_' . $id, 0, 300));
    return $app['twig']->render('event_checkin.html.twig', array('event' => $event, 'checkins' => $checkins));
})->bind('event_checkin');
// Checks a user into an event
$app->post('/user/checkin', function (Request $request) use($app) {
    $userId = $request->get('user_id');
    $eventId = $request->get('event_id');
    $client = new Client();
    $client->lpush('checkin_' . $eventId, $userId);
    return new Response(json_encode(array('result' => 'ok')), 200, array('Content-Type' => 'application/json'));
})->bind('user_checkin');
// Error page
$app->error(function (\Exception $e, $code) use($app) {
    if ($app['debug']) {
        return;
    }
    $page = 404 == $code ? '404.html' : '500.html';
    return new Response($app['twig']->render($page, array('code' => $code)), $code);
});
// Oauth Handshake
$app->get('/oauth/authorize', function (Request $request) use($app) {
    /** @var MeetupOauthHandler $oauthHandler */
    $oauthHandler = $app['meetup_oauth_handler'];
    $oauthHandler->clearSessionToken();
开发者ID:ShawnMcCool,项目名称:meetup-raffle-machine,代码行数:31,代码来源:controllers.php

示例14: Client

<?php

$loader = (require __DIR__ . '/../vendor/autoload.php');
$loader->add('Activity', __DIR__);
use Predis\Client;
use TylerKing\Activity\Broadcast;
use TylerKing\Activity\Feed;
use Activity\Status;
use Activity\PhotoLike;
$redis = new Client();
// Setup some friends and the current user (you can use a database for this).
$redis->del('uid:1:friends');
$redis->del('feed:2');
$redis->lpush('uid:1:friends', 2);
$redis->lpush('uid:1:friends', 3);
$friends = $redis->lrange('uid:1:friends', 0, -1);
// Make a status.
$status = new Status($redis);
$status->setCreator(1);
$status->setStatus('Hey, I just joined this site!');
// Broadcast status to user's friends...
$broadcast = new Broadcast($redis);
$broadcast->setActivity($status);
$broadcast->setTo($friends);
$broadcast->flush();
// Make a photo like.
$like = new PhotoLike($redis);
$like->setCreator(1);
$like->setPhotoId(5);
$like->setPhoto('http://i.imgur.com/pcS7V.jpg');
// Broadcast photo like to user's friends...
开发者ID:tyler-king,项目名称:activity,代码行数:31,代码来源:ShowFeed.php

示例15: lpush

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


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