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


PHP Client::lrange方法代码示例

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


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

示例1: getErrors

 public function getErrors()
 {
     $jsonEntries = $this->redisClient->lrange($this->errorKey, 0, 99);
     $entries = [];
     foreach ($jsonEntries as $entry) {
         $entries[] = json_decode($entry, true);
     }
     return $entries;
 }
开发者ID:atawsports2,项目名称:Imagick-demos,代码行数:9,代码来源:RedisTaskQueue.php

示例2: showAllPosts

 /**
  * @return array
  */
 public function showAllPosts()
 {
     $key = "global:timeline";
     $posts = $this->redisClient->lrange($key, 0, 10);
     $postData = [];
     foreach ($posts as $post) {
         $postData[] = $this->redisClient->get("post:{$post}");
     }
     return $postData;
 }
开发者ID:KrunoKnego,项目名称:Symfony-Twitter-Clone,代码行数:13,代码来源:RedisTweet.php

示例3: getEventsFor

 public function getEventsFor($id)
 {
     if (!$this->predis->exists('events:' . $id)) {
         throw new AggregateDoesNotExist($id);
     }
     $serializedEvents = $this->predis->lrange('events:' . $id, 0, -1);
     $eventStream = [];
     foreach ($serializedEvents as $serializedEvent) {
         $eventData = $this->serializer->deserialize($serializedEvent, 'array', 'json');
         $eventStream[] = $this->serializer->deserialize($eventData['data'], $eventData['type'], 'json');
     }
     return new EventStream($id, $eventStream);
 }
开发者ID:dddinphp,项目名称:last-wishes-gamify,代码行数:13,代码来源:RedisEventStore.php

示例4: peek

 /**
  * Peek for messages
  *
  * @param integer $limit
  * @return array Messages or empty array if no messages were present
  */
 public function peek($limit = 1)
 {
     $result = $this->client->lrange("queue:{$this->name}:messages", -$limit, -1);
     if (is_array($result) && count($result) > 0) {
         $messages = [];
         foreach ($result as $value) {
             $message = $this->decodeMessage($value);
             // The message is still published and should not be processed!
             $message->setState(\Flowpack\JobQueue\Common\Queue\Message::STATE_SUBMITTED);
             $messages[] = $message;
         }
         return $messages;
     }
     return [];
 }
开发者ID:admaykin,项目名称:Admaykin.Jobqueue.Redis,代码行数:21,代码来源:RedisQueue.php

示例5: checkKeyExists

 /**
  * Checks whether a key exists and, optionally, whether it has a given $value
  *
  * @param string $key   The key name
  * @param mixed  $value Optional. If specified, also checks the key has this
  * value. Booleans will be converted to 1 and 0 (even inside arrays)
  *
  * @return bool
  */
 private function checkKeyExists($key, $value = null)
 {
     $type = $this->driver->type($key);
     if (is_null($value)) {
         return $type != 'none';
     }
     $value = $this->boolToString($value);
     switch ($type) {
         case 'string':
             $reply = $this->driver->get($key);
             // Allow non strict equality (2 equals '2')
             $result = $reply == $value;
             break;
         case 'list':
             $reply = $this->driver->lrange($key, 0, -1);
             // Check both arrays have the same key/value pairs + same order
             $result = $reply === $value;
             break;
         case 'set':
             $reply = $this->driver->smembers($key);
             // Only check both arrays have the same values
             sort($reply);
             sort($value);
             $result = $reply === $value;
             break;
         case 'zset':
             $reply = $this->driver->zrange($key, 0, -1, 'WITHSCORES');
             // Check both arrays have the same key/value pairs + same order
             $reply = $this->scoresToFloat($reply);
             $value = $this->scoresToFloat($value);
             $result = $reply === $value;
             break;
         case 'hash':
             $reply = $this->driver->hgetall($key);
             // Only check both arrays have the same key/value pairs (==)
             $result = $reply == $value;
             break;
         default:
             $result = false;
     }
     return $result;
 }
开发者ID:solutionDrive,项目名称:Codeception,代码行数:51,代码来源:Redis.php

示例6: getPendingCommands

 /**
  * Returns an array of pending commands on the destination queue.
  * If the destination is <code>null</code> commands from the local node queue are returned.
  *
  * @param string|null $destination
  * @return array
  */
 public function getPendingCommands($destination = null)
 {
     $destination = $destination ? $destination : $this->nodeName;
     return $this->client->lrange(sprintf(self::COMMAND_QUEUE_KEY, $destination), 0, -1);
 }
开发者ID:fcm,项目名称:GovernorFramework,代码行数:12,代码来源:RedisTemplate.php

示例7: function

$app->get('/', function () use($app) {
    return $app['twig']->render('index.html.twig', array('meetups' => $app['meetup']->getEvents()));
})->bind('homepage');
// Specific event
$app->get('/event/{id}', function ($id) use($app) {
    $event = $app['meetup']->getEvent($id);
    $client = new Client();
    $checkins = array_filter($client->lrange('checkin_' . $id, 0, 300));
    $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;
    }
开发者ID:ShawnMcCool,项目名称:meetup-raffle-machine,代码行数:31,代码来源:controllers.php

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

示例9: getList

 /**
  * 获取列表数据
  *  默认取出全部
  * @param string $key
  * @param int $start 起始位置
  * @param int $stop 结束位置
  * @return array
  */
 public function getList($key, $start = 0, $stop = -1)
 {
     // list:magazine:100:images 12 13 14
     return $this->redis->lrange($key, $start, $stop);
 }
开发者ID:inhere,项目名称:php-librarys,代码行数:13,代码来源:Redis.php


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