本文整理汇总了PHP中Predis\Client::smembers方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::smembers方法的具体用法?PHP Client::smembers怎么用?PHP Client::smembers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Predis\Client
的用法示例。
在下文中一共展示了Client::smembers方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateValues
/**
*
*/
private function updateValues()
{
$this->registeredStates = $this->redis->smembers(self::STATE_MACHINE_NAMESPACE . 'registry');
if (count($this->registeredStates) > 0) {
$currentValueRedisKeys = array_map([$this, 'buildCurrentKey'], $this->registeredStates);
$previousValueRedisKeys = array_map([$this, 'buildPreviousKey'], $this->registeredStates);
list($currentValues, $previousValues) = $this->redis->pipeline(function (Pipeline $pipe) use($currentValueRedisKeys, $previousValueRedisKeys) {
$pipe->mget($currentValueRedisKeys);
$pipe->mget($previousValueRedisKeys);
});
$this->currentValues = array_combine($this->registeredStates, $currentValues);
$this->previousValues = array_combine($this->registeredStates, $previousValues);
}
}
示例2: 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);
}
示例3: remAllKeys
private static function remAllKeys()
{
$keys = array();
$prefix_key = Key::getIndexKey();
$prefixes = self::$_redis->smembers($prefix_key);
foreach ($prefixes as $prefix) {
$suffixes = self::$_redis->smembers($prefix);
foreach ($suffixes as $suffix) {
$keys[] = Key::fromString($prefix . ":" . $suffix);
}
}
return $keys;
}
示例4: 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;
}
示例5: getList
/**
* @inheritdoc
*/
public function getList($listName)
{
return $this->predis->smembers($listName);
}
示例6: getOnlineUsers
/**
* Return all identifiers from set
* @return array
*/
public function getOnlineUsers()
{
return $this->redisClient->smembers($this->setName);
}
示例7: getSubscriptions
/**
* @param string $commandName
* @return array
*/
public function getSubscriptions($commandName)
{
return $this->client->smembers(sprintf(self::COMMAND_SUBSCRIPTION_KEY, $this->hashCommandName($commandName)));
}
示例8: getOnlineUsersIds
/**
* Запрос id всех игроков онлайн из redis
* @return int[]
*/
public function getOnlineUsersIds() : array
{
return $this->redis->smembers(RedisClientInterface::ONLINE_LIST);
}
示例9: getSimpleFriendsList
/**
* @param int $userId
* @return array
*/
public function getSimpleFriendsList($userId)
{
$key = sprintf(self::TEMPLATE_KEY, $userId);
return $this->redis->smembers($key);
}
示例10: getSet
/**
* 获取集合的全部数据
* @param $key
* @return array
*/
public function getSet($key)
{
return $this->redis->smembers($key);
}
示例11: getListOfRequester
/**
* @param int $userId
* @return array
*/
public function getListOfRequester($userId)
{
$key = sprintf(self::TEMPLATE_ADD_REQUEST, $userId);
return $this->redis->smembers($key);
}