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


PHP Client::hget方法代码示例

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


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

示例1: sort

 public function sort($tid, Request $request)
 {
     $sorts = BiliBiliHelper::getSorts();
     //分类非法检测
     if (!array_has($sorts, $tid)) {
         return $this->returnError('分类不存在');
     }
     $order = $request->get('order', 'hot');
     $page = $request->get('page', 1);
     //页码非法检测
     if ($page < 1) {
         $page = 1;
     }
     //默认取出redis
     if ($order == 'hot' && $page == 1) {
         $redis = new Client();
         $date = $redis->hget('update', 'sort');
         $sort = $redis->hget('sort', $sorts[$tid]);
         $sort = json_decode($sort, true);
     } else {
         try {
             $request_array = ['tid' => $tid, 'order' => $order, 'page' => $page, 'pagesize' => 20];
             $date = date('H:i:s');
             $back = RequestUtil::getUrl(BiliBiliHelper::$SERVICE_URL . '/sort?' . http_build_query($request_array));
             $sort = $back['content'];
         } catch (\Exception $e) {
             return $this->returnError('服务器君忙,待会再试吧...');
         }
     }
     return view('sort')->with('content', $sort)->with('tid', $tid)->with('page', $page)->with('date', $date);
 }
开发者ID:HouseStark,项目名称:BiliPusher,代码行数:31,代码来源:HomeController.php

示例2: read

 /**
  * Reads a session.
  *
  * @param  string $id  A session ID
  *
  * @return string      The session data if the session was read or created, otherwise an exception is thrown
  *
  * @throws \RuntimeException If the session cannot be read
  */
 public function read($key, $default = null)
 {
     if (null !== ($data = $this->db->hget($this->getHashKey(), $key))) {
         return @unserialize($data);
     }
     return $default;
 }
开发者ID:realestateconz,项目名称:SncRedisBundle,代码行数:16,代码来源:RedisSessionStorage.php

示例3: get

 /**
  * {@inheritDoc}
  */
 public function get($identifier, $type = null, $unique = null)
 {
     if (!is_null($type) && !is_null($unique)) {
         $identifier = base64_encode(implode(':', [$identifier, $type, $unique]));
     }
     return $this->redis->hget('aggregator:objects', $identifier);
 }
开发者ID:nonconforme,项目名称:aggregator,代码行数:10,代码来源:RedisAggregator.php

示例4: loadUserByUsername

 /**
  * @param string $username
  * @return UserVO
  * @throws UserNotFoundException
  */
 public function loadUserByUsername(string $username) : UserVO
 {
     $userId = $this->redis->hget(UserProvider::REDIS_USER_NAMES, mb_strtolower($username));
     if (empty($userId)) {
         throw new UserNotFoundException(sprintf('Username "%s" does not exist.', $username));
     }
     return $this->loadUserById($userId);
 }
开发者ID:brainexe,项目名称:core,代码行数:13,代码来源:LoadUser.php

示例5: getById

 /**
  * @param $id
  * @return DirectoryView
  */
 public function getById($id) : DirectoryView
 {
     if (!($name = $this->client->hget($this->key, $id))) {
         $model = $this->repository->getById($id);
         $this->client->hset($this->key, $model->getId(), $model->getName());
         return $model;
     }
     /** @var DirectoryView $viewClass */
     $viewClass = $this->viewClass;
     return $viewClass::create($id, $name);
 }
开发者ID:igaponov,项目名称:shop,代码行数:15,代码来源:DirectoryViewRepository.php

示例6: htDecrField

 /**
  * @param string $key
  * @param string $field 计数field
  * @param int $step
  * @param bool $zeroLimit 最小为零限制 限制最小可以自减到 0
  * @return int
  */
 public function htDecrField($key, $field, $step = 1, $zeroLimit = true)
 {
     // fix: not allow lt 0
     if ($zeroLimit && (int) $this->redis->hget($key, $field) <= 0) {
         return 0;
     }
     return $this->redis->hincrby($key, $field, -$step);
 }
开发者ID:inhere,项目名称:php-librarys,代码行数:15,代码来源:Redis.php

示例7: 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;
 }
开发者ID:Doanlmit,项目名称:pickleweb,代码行数:20,代码来源:ExtensionRepository.php

示例8: remGetCached

 /**
  * Get a cached value from Redis.
  * @param string $id
  * @param string $method
  * @param array $args
  * @return mixed unserialized value
  */
 private static function remGetCached($key)
 {
     $value = self::$_redis->hget($key, 'val');
     if (null !== $value && "" !== $value) {
         $value = unserialize($value);
     }
     return $value;
 }
开发者ID:chriskite,项目名称:rem,代码行数:15,代码来源:Rem.php

示例9: export

 /**
  * @return mixed
  */
 public function export()
 {
     if ($this->redis) {
         $keys = $this->redis->hkeys($this->key);
         foreach ($keys as $key) {
             $v = $this->redis->hget($this->key, $key);
             $v = unserialize($v);
             $this->conf[$key] = $v;
         }
     }
     return parent::export();
 }
开发者ID:wwtg99,项目名称:config,代码行数:15,代码来源:RedisSource.php

示例10: checkKeyContains

 /**
  * Checks whether a key contains a given item
  *
  * @param string $key       The key
  * @param mixed  $item      The item
  * @param null   $itemValue Optional and only used for zsets and hashes. If
  * specified, the method will also check that the $item has this value/score
  *
  * @return bool
  *
  * @throws ModuleException
  */
 private function checkKeyContains($key, $item, $itemValue = null)
 {
     $result = null;
     if (!is_scalar($item)) {
         throw new ModuleException($this, "All arguments of [dont]seeRedisKeyContains() must be scalars");
     }
     switch ($this->driver->type($key)) {
         case 'string':
             $reply = $this->driver->get($key);
             $result = strpos($reply, $item) !== false;
             break;
         case 'list':
             $reply = $this->driver->lrange($key, 0, -1);
             $result = in_array($item, $reply);
             break;
         case 'set':
             $result = $this->driver->sismember($key, $item);
             break;
         case 'zset':
             $reply = $this->driver->zscore($key, $item);
             if (is_null($reply)) {
                 $result = false;
             } elseif (!is_null($itemValue)) {
                 $result = (double) $reply === (double) $itemValue;
             } else {
                 $result = true;
             }
             break;
         case 'hash':
             $reply = $this->driver->hget($key, $item);
             $result = is_null($itemValue) ? !is_null($reply) : (string) $reply === (string) $itemValue;
             break;
         case 'none':
             throw new ModuleException($this, "Key \"{$key}\" does not exist");
             break;
     }
     return $result;
 }
开发者ID:solutionDrive,项目名称:Codeception,代码行数:50,代码来源:Redis.php

示例11: usort

        $messageArr = json_decode($message, true);
        $messageArr['id'] = $id;
        $result[] = $messageArr;
    }
    usort($result, function ($a, $b) {
        if ($a['id'] == $b['id']) {
            return 0;
        }
        return $a['id'] < $b['id'] ? -1 : 1;
    });
    $app->response->headers->set('Content-Type', 'application/json');
    $app->response->setStatus(200);
    echo json_encode($result);
});
$app->get('/messages/:id', function ($id) use($predis, $app) {
    $data = $predis->hget(BULK_HASH, $id);
    if (!$data) {
        $app->response->setStatus(404);
        return;
    }
    $result = json_decode($data, true);
    $result['id'] = $id;
    $app->response->headers->set('Content-Type', 'application/json');
    $app->response->setStatus(200);
    echo json_encode($result);
});
$app->delete('/messages/:id', function ($id) use($predis, $app) {
    $data = $predis->hget(BULK_HASH, $id);
    if (!$data) {
        $app->response->setStatus(404);
        return;
开发者ID:rukavina,项目名称:sms-bulk-mock,代码行数:31,代码来源:rest.php

示例12: getEmailCount

 /**
  * @param $email
  * @return int
  */
 protected function getEmailCount($email)
 {
     $throttles = $this->redis->hget($this->key('email'), $email);
     return $throttles ?: 0;
 }
开发者ID:jaffle-be,项目名称:framework,代码行数:9,代码来源:ThrottleManager.php

示例13: getRoutingDestination

 /**
  * @param string $commandName
  * @param string $routingKey
  * @return string|null
  */
 public function getRoutingDestination($commandName, $routingKey)
 {
     return $this->client->hget(self::COMMAND_ROUTING_KEY, $this->hashCommandRouting($commandName, $routingKey));
 }
开发者ID:fcm,项目名称:GovernorFramework,代码行数:9,代码来源:RedisTemplate.php

示例14: findByProviderApiKey

 /**
  * @param string $provider
  * @param string $id
  *
  * @return null|User
  */
 public function findByProviderApiKey($provider, $key)
 {
     $email = $this->redisClient->hget($provider . '_API_' . self::USER_HASH_STORE, $id);
     return empty($email) ? null : $this->find($email);
 }
开发者ID:Doanlmit,项目名称:pickleweb,代码行数:11,代码来源:UserRepository.php

示例15: get

 /**
  * {@inheritdoc}
  */
 public function get(string $alias) : FeatureInterface
 {
     return unserialize($this->redis->hget($this->prefix, $alias));
 }
开发者ID:jadb,项目名称:feature_toggle,代码行数:7,代码来源:RedisStorage.php


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