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


PHP Redis::hGet方法代码示例

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


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

示例1: it_can_hget

 public function it_can_hget()
 {
     $this->redis->hGet('test', 'test')->shouldBeCalled()->willReturn('test');
     $this->hGet('test', 'test')->shouldReturn('test');
     $this->redis->hGet('test', 'test')->willThrow(new \RedisException());
     $this->shouldThrow(DriverException::class)->during('hGet', ['test', 'test']);
 }
开发者ID:mgdigital,项目名称:busque,代码行数:7,代码来源:PHPRedisAdapterSpec.php

示例2: getParentById

 /**
  * 根据 category_id 获取顶级分类的信息
  * @param $categoriesId
  * @return array
  */
 public function getParentById($categoriesId)
 {
     if ($this->redis->hLen($this->redisParentChildKey) == 0) {
         $this->setRedisCategoryParentChild();
     }
     $parentId = $this->redis->hGet($this->redisParentChildKey, $categoriesId);
     return ['categories_id' => $parentId, 'categories_name' => $this->getCategoryNameById($parentId)];
 }
开发者ID:xidiao,项目名称:gxfenxi,代码行数:13,代码来源:CategoryRedis.php

示例3: get

 /**
  * get var
  *
  * @param $key
  * @param null $default
  * @return bool|string|null
  */
 public function get($key, $default = null)
 {
     $result = $this->redis->hGet($this->prefix, $key);
     if ($result !== false) {
         return $result;
     }
     return $default;
 }
开发者ID:huyanping,项目名称:simple-fork-php,代码行数:15,代码来源:RedisCache.php

示例4: settings

 public static function settings($app)
 {
     $html = new simple_html_dom();
     $html->load_file($app->rootUri . "/settings");
     $selects = $html->find('select');
     $inputs = $html->find('input');
     $boxes = $html->find('#features-management', 0);
     // connect to the database
     $redis = new \Redis();
     $redis->pconnect('127.0.0.1');
     $obj = array("settings" => array("environment" => array("hostname" => $redis->get('hostname'), "ntp_server" => $redis->get('ntpserver'), "timezone" => $redis->get('timezone')), "kernel" => array("i2s_modules" => $redis->get('i2smodule')), "features" => array("airplay" => $redis->hGet('airplay', 'enable'), "airplay_name" => $redis->hGet('airplay', 'name'), "spotify" => $redis->hGet('spotify', 'enable'), "spotify_username" => $redis->hGet('spotify', 'user'), "spotify_password" => $redis->hGet('spotify', 'pass'), "upnp_dlna" => $redis->hGet('dlna', 'enable'), "upnp_dlna_name" => $redis->hGet('dlna', 'name'), "usb_automount" => $redis->get('udevil'), "coverart" => $redis->get('coverart'), "lastfm" => $redis->hGet('lastfm', 'enable'), "lastfm_username" => $redis->hGet('lastfm', 'user'), "lastfm_password" => $redis->hGet('lastfm', 'pass')), "compatibility_fix" => array("cmedia_fix" => "unknown")));
     echo json_encode($obj);
 }
开发者ID:LP-CISIIE,项目名称:RuneAPI,代码行数:13,代码来源:settingsController.php

示例5: get

 /**
  * Get entry from cache storage
  *
  * @param string $key
  *
  * @return mixed
  */
 public function get($key)
 {
     $entry = $this->redis->hGet($this->cacheKey, $key);
     if ($entry) {
         $entry = unserialize($entry);
         if ($entry['expire']) {
             // Check expires
             $now = new \DateTime('now', new \DateTimeZone('UTC'));
             if ((int) $now->format('U') > $entry['expire']) {
                 $this->remove($key);
                 return null;
             }
         }
         return $entry['value'];
     }
     return null;
 }
开发者ID:Gtvar,项目名称:FivePercent-Cache,代码行数:24,代码来源:RedisCache.php

示例6: getMessageById

 /**
  * @param string $messageId
  * @return Message
  */
 protected function getMessageById($messageId)
 {
     if (!is_string($messageId)) {
         return null;
     }
     $encodedPayload = $this->client->hGet("queue:{$this->name}:ids", $messageId);
     $numberOfReleases = (int) $this->client->hGet("queue:{$this->name}:releases", $messageId);
     return new Message($messageId, json_decode($encodedPayload, true), $numberOfReleases);
 }
开发者ID:flowpack,项目名称:jobqueue-redis,代码行数:13,代码来源:RedisQueue.php

示例7: hget

 /**
  * hGet cache
  *
  * @param	string	Cache ID
  * @return	mixed
  */
 public function hget($key, $hashkey)
 {
     $value = $this->_redis->hGet($key, $hashkey);
     if ($value !== FALSE && isset($this->_serialized[$key])) {
         //die($value);
         return unserialize(base64_decode($value));
     }
     return $value;
 }
开发者ID:KodeStar,项目名称:pro-api,代码行数:15,代码来源:Cache_redis.php

示例8: testHashes

 public function testHashes()
 {
     $this->redis->delete('h', 'key');
     $this->assertTrue(0 === $this->redis->hLen('h'));
     $this->assertTrue(TRUE === $this->redis->hSet('h', 'a', 'a-value'));
     $this->assertTrue(1 === $this->redis->hLen('h'));
     $this->assertTrue(TRUE === $this->redis->hSet('h', 'b', 'b-value'));
     $this->assertTrue(2 === $this->redis->hLen('h'));
     $this->assertTrue('a-value' === $this->redis->hGet('h', 'a'));
     // simple get
     $this->assertTrue('b-value' === $this->redis->hGet('h', 'b'));
     // simple get
     $this->assertTrue(FALSE === $this->redis->hSet('h', 'a', 'another-value'));
     // replacement
     $this->assertTrue('another-value' === $this->redis->hGet('h', 'a'));
     // get the new value
     $this->assertTrue('b-value' === $this->redis->hGet('h', 'b'));
     // simple get
     $this->assertTrue(FALSE === $this->redis->hGet('h', 'c'));
     // unknown hash member
     $this->assertTrue(FALSE === $this->redis->hGet('key', 'c'));
     // unknownkey
     // hDel
     $this->assertTrue(TRUE === $this->redis->hDel('h', 'a'));
     // TRUE on success
     $this->assertTrue(FALSE === $this->redis->hDel('h', 'a'));
     // FALSE on failure
     $this->redis->delete('h');
     $this->redis->hSet('h', 'x', 'a');
     $this->redis->hSet('h', 'y', 'b');
     // keys
     $keys = $this->redis->hKeys('h');
     $this->assertTrue($keys === array('x', 'y') || $keys === array('y', 'x'));
     // values
     $values = $this->redis->hVals('h');
     $this->assertTrue($values === array('a', 'b') || $values === array('b', 'a'));
     // keys + values
     $all = $this->redis->hGetAll('h');
     $this->assertTrue($all === array('x' => 'a', 'y' => 'b') || $all === array('y' => 'b', 'x' => 'a'));
     // hExists
     $this->assertTrue(TRUE === $this->redis->hExists('h', 'x'));
     $this->assertTrue(TRUE === $this->redis->hExists('h', 'y'));
     $this->assertTrue(FALSE === $this->redis->hExists('h', 'w'));
     $this->redis->delete('h');
     $this->assertTrue(FALSE === $this->redis->hExists('h', 'x'));
     // hIncrBy
     /*
     $this->redis->delete('h');
     $this->assertTrue(2.5 === $this->redis->hIncrBy('h', 2.5, 'x'));
     $this->assertTrue(3.5 === $this->redis->hIncrBy('h', 1, 'x'));
     
     $this->redis->hSet('h', 'y', 'not-a-number');
     $this->assertTrue(FALSE === $this->redis->hIncrBy('h', 1, 'y'));
     */
 }
开发者ID:korsunivan,项目名称:phpredis,代码行数:55,代码来源:TestRedis.php

示例9: handle

 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     // 避免重复操作
     if ($this->attempts() > 3) {
         return;
     }
     $this->redis = PRedis::connection();
     if (is_object($this->sheet)) {
         $vote_dest = 'jk_upvote:' . $this->sheet->getAttributeValue('song_id') . ':userLIST';
         if (true == $this->redis->hGet($vote_dest, $this->user)) {
             return;
         }
         $this->redis->hSet($vote_dest, $this->user, 1);
         $vote_count = $this->redis->hLen($vote_dest);
         $stat = $this->sheet->storeUpVoteNumber($this->sheet->getAttributeValue('song_id'), $vote_count);
         if (!$stat) {
             $this->failed();
         }
     }
 }
开发者ID:RedrockTeam,项目名称:jukebox,代码行数:25,代码来源:UpVote.php

示例10: getHashValueAsUnserializedString

 /**
  * @param string                   $key
  * @param string                   $hashKey
  * @param UnserializesDataToString $unserializer
  *
  * @return bool|string
  */
 public function getHashValueAsUnserializedString($key, $hashKey, UnserializesDataToString $unserializer)
 {
     $serializer = $this->redis->getOption(\Redis::OPT_SERIALIZER);
     $this->redis->setOption(\Redis::OPT_SERIALIZER, \Redis::SERIALIZER_NONE);
     $value = $this->redis->hGet($key, $hashKey);
     if ($value !== false) {
         $unserializedValue = $unserializer->unserialize($value);
     } else {
         $unserializedValue = false;
     }
     $this->redis->setOption(\Redis::OPT_SERIALIZER, $serializer);
     return $unserializedValue;
 }
开发者ID:hollodotme,项目名称:readis,代码行数:20,代码来源:ServerManager.php

示例11: requeueOldWorkingMessages

 private function requeueOldWorkingMessages($type)
 {
     $messageIds = array_unique($this->redis->lRange($this->getMessageRunKey($type), 0, -1));
     foreach ($messageIds as $messageId) {
         $time = $this->redis->hGet($this->getMessageStartTimeKey($type), $messageId);
         if (!empty($time) && time() > $this->messageTimeout + (int) $time) {
             $this->redis->multi();
             $this->redis->rPush($this->getMessageQueueKey($type), $messageId);
             $this->redis->lRem($this->getMessageRunKey($type), $messageId, 1);
             $this->redis->hDel($this->getMessageStartTimeKey($type), $messageId);
             $this->redis->exec();
         }
     }
 }
开发者ID:parallel-php,项目名称:parallel-task,代码行数:14,代码来源:RedisQueue.php

示例12: getPeriodic

 /**
  * 获取周期任务的ID列表
  *
  * @param string|null $tubeName
  * @return array
  */
 public function getPeriodic($tubeName = null)
 {
     $container = array();
     $ret = $this->getDelayed($tubeName);
     if (is_array($ret)) {
         foreach ($ret as $jobId) {
             $periodic = $this->client->hGet($this->name . ':' . Job::JOB_TAB . ':' . $jobId, 'periodic');
             if ($periodic > 0) {
                 $container[] = $jobId;
             }
         }
     }
     return $container;
 }
开发者ID:lezhizhe,项目名称:RedisQueue-as-like-beanstalkd,代码行数:20,代码来源:Queue.php

示例13: getReadyJob

 /**
  * 获取一个任务
  *
  * @return bool|Caster
  */
 private function getReadyJob()
 {
     $keyChip = $this->queue->name . ':' . Job::JOBS_TAB . ':' . $this->tube . ':';
     $timePort = Util::now();
     $this->expireActivate($keyChip, $timePort);
     if (!($id = $this->pop($keyChip . Job::STATE_READY, $timePort))) {
         return false;
     }
     if (!($job = Caster::reload($id))) {
         return false;
     }
     $this->client->hIncrBy($this->queue->name . ':' . Job::JOB_TAB . ':' . $id, 'retry_times', 1);
     $this->jobId = $id;
     $this->periodic = $this->client->hGet($this->queue->name . ':' . Job::JOB_TAB . ':' . $id, 'periodic');
     return $job;
 }
开发者ID:lezhizhe,项目名称:RedisQueue-as-like-beanstalkd,代码行数:21,代码来源:Portal.php

示例14: getResult

 public function getResult($taskId)
 {
     $serializedTaskResult = $this->redis->hGet($this->getTaskResultKey(), $taskId);
     if (empty($serializedTaskResult)) {
         return null;
     }
     do {
         $resultReady = $this->redis->blPop($this->getTaskResultReadyKey($taskId), 1);
     } while (empty($resultReady));
     $serializedTaskResult = $this->redis->hGet($this->getTaskResultKey(), $taskId);
     $taskResult = unserialize($serializedTaskResult);
     $this->redis->hDel($this->getTaskResultKey(), $taskId);
     if ($taskResult instanceof TaskException) {
         throw $taskResult;
     }
     return $taskResult;
 }
开发者ID:drealecs,项目名称:thread-worker,代码行数:17,代码来源:RedisQueue.php

示例15: testHashes

 public function testHashes()
 {
     $this->redis->delete('h', 'key');
     $this->assertTrue(0 === $this->redis->hLen('h'));
     $this->assertTrue(TRUE === $this->redis->hSet('h', 'a', 'a-value'));
     $this->assertTrue(1 === $this->redis->hLen('h'));
     $this->assertTrue(TRUE === $this->redis->hSet('h', 'b', 'b-value'));
     $this->assertTrue(2 === $this->redis->hLen('h'));
     $this->assertTrue('a-value' === $this->redis->hGet('h', 'a'));
     // simple get
     $this->assertTrue('b-value' === $this->redis->hGet('h', 'b'));
     // simple get
     $this->assertTrue(FALSE === $this->redis->hSet('h', 'a', 'another-value'));
     // replacement
     $this->assertTrue('another-value' === $this->redis->hGet('h', 'a'));
     // get the new value
     $this->assertTrue('b-value' === $this->redis->hGet('h', 'b'));
     // simple get
     $this->assertTrue(FALSE === $this->redis->hGet('h', 'c'));
     // unknown hash member
     $this->assertTrue(FALSE === $this->redis->hGet('key', 'c'));
     // unknownkey
     // hDel
     $this->assertTrue(TRUE === $this->redis->hDel('h', 'a'));
     // TRUE on success
     $this->assertTrue(FALSE === $this->redis->hDel('h', 'a'));
     // FALSE on failure
     $this->redis->delete('h');
     $this->redis->hSet('h', 'x', 'a');
     $this->redis->hSet('h', 'y', 'b');
     // keys
     $keys = $this->redis->hKeys('h');
     $this->assertTrue($keys === array('x', 'y') || $keys === array('y', 'x'));
     // values
     $values = $this->redis->hVals('h');
     $this->assertTrue($values === array('a', 'b') || $values === array('b', 'a'));
     // keys + values
     $all = $this->redis->hGetAll('h');
     $this->assertTrue($all === array('x' => 'a', 'y' => 'b') || $all === array('y' => 'b', 'x' => 'a'));
     // hExists
     $this->assertTrue(TRUE === $this->redis->hExists('h', 'x'));
     $this->assertTrue(TRUE === $this->redis->hExists('h', 'y'));
     $this->assertTrue(FALSE === $this->redis->hExists('h', 'w'));
     $this->redis->delete('h');
     $this->assertTrue(FALSE === $this->redis->hExists('h', 'x'));
     // hIncrBy
     $this->redis->delete('h');
     $this->assertTrue(25 === $this->redis->hIncrBy('h', 'x', 25));
     $this->assertTrue(35 === $this->redis->hIncrBy('h', 'x', 10));
     $this->redis->hSet('h', 'y', 'not-a-number');
     $this->assertTrue(FALSE === $this->redis->hIncrBy('h', 'y', 1));
     $this->redis->delete('h1');
     //hMGet, hMSet
     $this->redis->hset("h1", "field1", "value1");
     $this->redis->hset("h1", "field2", "value2");
     $this->assertTrue(array('field1' => 'value1', 'field2' => 'value2') === $this->redis->hGetAll('h1'));
     $this->assertTrue(array('field1' => 'value1', 'field2' => 'value2') === $this->redis->hMGet('h1', array('field1', 'field2')));
     $this->assertTrue(array('field1' => 'value1') === $this->redis->hMGet('h1', array('field1')));
     $this->assertTrue(FALSE === $this->redis->hMGet('h1', array()));
     $this->assertTrue(TRUE === $this->redis->hMSet('h1', array('field3' => 'value3')));
     $this->assertTrue(array('field1' => 'value1', 'field2' => 'value2', 'field3' => 'value3') === $this->redis->hGetAll('h1'));
     $this->assertTrue(TRUE === $this->redis->hMSet('h1', array('field3' => 'value4')));
     $this->assertTrue(array('field1' => 'value1', 'field2' => 'value2', 'field3' => 'value4') === $this->redis->hGetAll('h1'));
     $this->assertTrue(TRUE === $this->redis->hMSet('h1', array('x' => 0, 'y' => array(), 'z' => new stdclass())));
     $h1 = $this->redis->hGetAll('h1');
     $this->assertTrue('0' === $h1['x']);
     $this->assertTrue('Array' === $h1['y']);
     $this->assertTrue('Object' === $h1['z']);
 }
开发者ID:virtulis,项目名称:phpredis,代码行数:69,代码来源:TestRedis.php


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