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


PHP Client::ltrim方法代码示例

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


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

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

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

示例3: clearErrors

 public function clearErrors()
 {
     $this->redisClient->ltrim($this->errorKey, 100, -1);
 }
开发者ID:atawsports2,项目名称:Imagick-demos,代码行数:4,代码来源:RedisTaskQueue.php


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