本文整理汇总了PHP中Predis\Client::hgetall方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::hgetall方法的具体用法?PHP Client::hgetall怎么用?PHP Client::hgetall使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Predis\Client
的用法示例。
在下文中一共展示了Client::hgetall方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getList
/**
* @param int $fireTime
*
* @return array
*/
public function getList($fireTime)
{
$list = $this->client->hgetall($this->makeKey($fireTime));
return array_map(function ($value) {
return json_decode($value, true);
}, $list);
}
示例2: index
/**
* {@inheritdoc}
*/
public function index() : array
{
$features = [];
foreach ($this->redis->hgetall($this->prefix) as $alias => $feature) {
$features[$alias] = unserialize($feature);
}
return $features;
}
示例3: loadUserById
/**
* @param int $userId
* @return UserVO
* @throws UserNotFoundException
*/
public function loadUserById(int $userId) : UserVO
{
$redisUser = $this->redis->hgetall($this->getKey($userId));
if (empty($redisUser)) {
throw new UserNotFoundException(sprintf('User "%d" does not exist.', $userId));
}
return $this->buildUserVO($userId, $redisUser);
}
示例4: getUserInfo
/**
* @param string $sessionId
* @return array
*/
public function getUserInfo($sessionId)
{
$userInfo = $this->redis->hgetall('session_' . $sessionId);
if (!$userInfo) {
throw new \RuntimeException('Session not found');
}
return $userInfo;
}
示例5: getRateInfo
public function getRateInfo($key)
{
$info = $this->client->hgetall($key);
$rateLimitInfo = new RateLimitInfo();
$rateLimitInfo->setLimit($info['limit']);
$rateLimitInfo->setCalls($info['calls']);
$rateLimitInfo->setResetTimestamp($info['reset']);
return $rateLimitInfo;
}
示例6: get
/**
* @param string $sid
*
* @return Session|null
*/
public function get($sid)
{
$session = null;
if (UUID::isValid($sid)) {
$data = $this->redis->hgetall($this->buildKey($sid));
if (count($data)) {
$session = new Session($sid, $this->getRealm(), $data);
}
}
return $session;
}
示例7: getById
/**
* @inheritdoc
*/
public function getById(\string $id) : CustomerView
{
$key = self::KEY . ':' . $id;
if ($this->client->exists($key)) {
$item = $this->client->hgetall($key);
$model = $this->createViewModel($item);
} else {
$model = $this->repository->getById($id);
$this->save($model);
}
return $model;
}
示例8: getAllIndexed
/**
* @inheritDoc
*/
public function getAllIndexed() : array
{
if (!$this->client->exists($this->key)) {
$data = $this->repository->getAllIndexed();
if ($data) {
$this->client->hmset($this->key, $data);
}
} else {
$data = $this->client->hgetall($this->key);
}
return $data;
}
示例9: testHandleLogWithJob
public function testHandleLogWithJob()
{
$job = new ImageJob();
$job->setBeginning('begin');
$job->setEnd('end');
$frame = new Frame('MESSAGE', array('delivery_tag' => 'delivery-' . mt_rand()), $job->toJson());
$loop = LoopFactory::create();
$options = array('eventloop' => $loop, 'on_error' => array($this, 'throwRedisError'));
$redisSync = new PredisSync('tcp://127.0.0.1:6379');
$redisSync->connect();
$resolver = $this->getResolver();
$resolver->expects($this->once())->method('ack');
$done = false;
$phpunit = $this;
$redis = new PredisAsync('tcp://127.0.0.1:6379', $options);
$redis->connect(function () use($phpunit, $redis, $frame, $redisSync, &$done, $resolver) {
$component = new LogBuilderComponent();
$component->handleLog($redis, $phpunit->getLogger(), $frame, $resolver)->then(function ($hashId) use($phpunit, $redis, $redisSync, &$done) {
$redis->disconnect();
$data = $redisSync->hgetall($hashId);
$phpunit->assertGreaterThan(0, count($data));
$phpunit->assertEquals('Gloubster\\Message\\Job\\ImageJob', $data['type']);
$phpunit->assertTrue($redisSync->sismember('jobs', $hashId));
$done = true;
});
});
$loop->run();
$this->assertTrue($done);
}
示例10: getAll
/**
* @return array|null
*/
public function getAll()
{
$extensionsSerialize = $this->redisClient->hgetall(self::EXTENSION_HASH_STORE);
if (!$extensionsSerialize) {
return;
}
$result = [];
foreach ($extensionsSerialize as $serialized) {
$extension = new Extension();
$extension->unserialize($serialized);
$meta = json_decode($this->redisClient->hget(self::EXTENSIONMETA_HASH_STORE, $extension->getName()), true);
$extension->setWatchers($meta['watchers']);
$extension->setStars($meta['stars']);
$result[$extension->getName()] = $extension;
}
return $result;
}
示例11: find
/**
* @param mixed $id
*
* @return object
*/
public function find($id)
{
$metadata = $this->getMetadataFor($this->className);
$key = $this->keyNamingStrategy->getKeyName(array($metadata->getPrefix(), $id));
$data = $this->redis->hgetall($key);
if (empty($data)) {
return;
}
return $this->hydrator->hydrate($this->newObject(), $data, $metadata);
}
示例12: htGetAll
/**
* @param $key
* @param bool $valToInt
* @return array
*/
public function htGetAll($key, $valToInt = false)
{
$data = $this->redis->hgetall($key);
if ($valToInt) {
array_walk($data, function (&$val) {
$val = (int) $val;
});
}
return $data;
}
示例13: home
public function home()
{
$redis = new Client();
$date = $redis->hget('update', 'index');
$index = $redis->hgetall('index');
$sorts = array_values(BiliBiliHelper::getSorts());
foreach ($sorts as $sort) {
$index[$sort] = json_decode($index[$sort], true);
}
return view('index')->with('content', $index)->with('sorts', $sorts)->with('update_time', $date);
}
示例14: getDistributions
/**
* Get distributions given an event and a set of dates
*
* [
* "value3": 24,
* "value7": 13,
* "value8": 9,
* ]
*
* @param string $token Event
* @param string $event Token
* @param array $dates Dates
*
* @return array Distribution with totals
*/
public function getDistributions($token, $event, array $dates)
{
$distributions = [];
foreach ($dates as $date) {
$key = $this->generateEntryKey($token, $event, $date);
$partials = $this->redis->hgetall($key . '_distr');
foreach ($partials as $key => $value) {
$distributions[$key] = isset($partialTotals[$key]) ? $distributions[$key] + $value : $value;
}
}
arsort($distributions);
return $distributions;
}
示例15: recoverByRemoteAddress
/**
* @param string $remoteAddress
*
* @return Session|null
*/
public function recoverByRemoteAddress($remoteAddress)
{
$session = null;
$oracleData = $this->findSessionInOracleByRemoteAddress($remoteAddress);
if (count($oracleData) === 1) {
$sid = $oracleData[0]['sid'];
$redisKey = $this->buildKey($sid);
$data = $this->redis->hgetall($redisKey);
if (!$data) {
$data['userId'] = (int) $oracleData[0]['userId'];
$data['userScreenname'] = $oracleData[0]['userScreenname'];
}
$this->redis->hmset($redisKey, $data);
$this->redis->expire($redisKey, $this->getExpires());
$session = new Session($sid, $this->getRealm(), $data);
}
return $session;
}