本文整理汇总了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);
}
示例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);
}
示例3: clearErrors
public function clearErrors()
{
$this->redisClient->ltrim($this->errorKey, 100, -1);
}