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


PHP Redis::hGetAll方法代码示例

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


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

示例1: loadScan

 /**
  * @param $siteUrl
  * @return array
  */
 public function loadScan($siteUrl)
 {
     $links = [];
     foreach ($this->getSitesKeys($siteUrl) as $pageUrl) {
         if ($link = $this->redis->hGetAll($this->getPageKey($siteUrl, $pageUrl))) {
             $links[] = $link;
         }
     }
     return $links;
 }
开发者ID:vedebel,项目名称:sitemap,代码行数:14,代码来源:RedisLinksStorage.php

示例2: getWorkers

 /**
  * Return all started workers arguments
  *
  * @return array An array of settings, by worker
  */
 public function getWorkers()
 {
     $workers = $this->redis->hGetAll(self::$workerKey);
     $temp = array();
     foreach ($workers as $name => $value) {
         $temp[$name] = unserialize($value);
     }
     return $temp;
 }
开发者ID:nosun,项目名称:php-resque-cronjob,代码行数:14,代码来源:ResqueStatus.php

示例3: 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

示例4: export

 /**
  * @inheritdoc
  */
 public function export($bucket, $type, $granularity, \DateTime $from, \DateTime $to = null)
 {
     if (null === $to) {
         $to = new \DateTime();
     }
     $granularities = $this->getGranularities();
     $settings = $granularities[$granularity];
     $keys = $this->getKeysForRange($bucket, $type, $granularity, $settings, $from, $to);
     $data = [];
     foreach ($keys as $key) {
         $all = $this->redis->hGetAll($key);
         foreach ($all as $stamp => $value) {
             if ($stamp >= $from->getTimestamp() && $stamp <= $to->getTimestamp()) {
                 $data[$stamp] = (int) $value;
             }
         }
     }
     ksort($data);
     return $data;
 }
开发者ID:fieg,项目名称:statistico,代码行数:23,代码来源:RedisDriver.php

示例5: array

 static function manager_area_data_load($area, $start = 0, $end = 9999999999)
 {
     $result = array();
     if ($start == 0 && $end == 9999999999) {
         //缓存中寻找数据
         try {
             $redis = new Redis();
         } catch (Exception $e) {
             echo $e->getMessage();
         }
         $redis->connect('127.0.0.1', 6379);
         $result = $redis->hGetAll('_' . $area);
     }
     //缓存中没有,去数据库查找
     if (empty($result)) {
         $list = self::through_area_get_school($area);
         $reg = 0;
         $reg_in = 0;
         $auth = 0;
         $auth_in = 0;
         //获得认证总数
         $remote = new maindb();
         foreach ($list as $v) {
             $num1 = $remote->count('p_user', '*', array('AND' => array('school' => $v, 'reg_time[>]' => $start, 'reg_time[<]' => $end)));
             $reg += $num1;
             $num2 = $remote->count('p_user', '*', array('AND' => array('school' => $v, 'reg_time[>]' => $start, 'reg_time[<]' => $end, 'invite[!]' => '')));
             $reg_in += $num2;
             $num3 = $remote->count('p_user', '*', array('AND' => array('school' => $v, 'auth_time[>]' => $start, 'auth' => 1, 'auth_time[<]' => $end)));
             $auth += $num3;
             $num4 = $remote->count('p_user', '*', array('AND' => array('school' => $v, 'auth_time[>]' => $start, 'auth' => 1, 'auth_time[<]' => $end, 'invite[!]' => '')));
             $auth_in += $num4;
         }
         $result = array('register_all' => $reg, 'authority_all' => $auth, 'register_invite' => $reg_in, 'authority_invite' => $auth_in, 'register_nature' => $reg - $reg_in, 'authority_nature' => $auth - $auth_in);
     }
     unset($redis);
     return $result;
 }
开发者ID:keensting,项目名称:ErhuoAmbass,代码行数:37,代码来源:school_handler.php

示例6: time

$from = $_GET['from'];
if (!$from || empty($from)) {
    $from = time() - 3600;
}
// get url
$url = $_GET['url'];
// result array
$result = array();
while ($from < time()) {
    $date = gmdate($format, $from);
    if (!$url || empty($url)) {
        // view total
        $total = 0;
        // home.php views
        $key = 'm|' . $date . '|0:mydomain.com/home.php';
        $arr = $redis->hGetAll($key);
        $total += $arr[1];
        // contactus.php views
        $key = 'm|' . $date . '|0:mydomain.com/contactus.php';
        $arr = $redis->hGetAll($key);
        $total += $arr[1];
        // contactus.php views
        $key = 'm|' . $date . '|0:mydomain.com/about.php';
        $arr = $redis->hGetAll($key);
        $total += $arr[1];
        // contactus.php views
        $key = 'm|' . $date . '|0:mydomain.com/support.php';
        $arr = $redis->hGetAll($key);
        $total += $arr[1];
        // products.php
        for ($i = 0; $i < 100; $i++) {
开发者ID:jbelke,项目名称:incubator-apex-malhar,代码行数:31,代码来源:PageViewTimeData.php

示例7: hGetAll

 /**
  * @param string $key
  * @return array
  */
 public function hGetAll($key)
 {
     return parent::hGetAll($key);
 }
开发者ID:sallyx,项目名称:redis-php-stream-wrapper,代码行数:8,代码来源:Redis.php

示例8: checkSerializer


//.........这里部分代码省略.........
     // zDelete
     $this->assertTrue(1 === $this->redis->zDelete('key', $z[3]));
     $this->assertTrue(0 === $this->redis->zDelete('key', $z[3]));
     unset($z[3]);
     // check that zDelete doesn't crash with a missing parameter (GitHub issue #102):
     $this->assertTrue(FALSE === @$this->redis->zDelete('key'));
     // variadic
     $this->redis->delete('k');
     $this->redis->zAdd('k', 0, 'a');
     $this->redis->zAdd('k', 1, 'b');
     $this->redis->zAdd('k', 2, 'c');
     $this->assertTrue(2 === $this->redis->zDelete('k', 'a', 'c'));
     $this->assertTrue(1.0 === $this->redis->zScore('k', 'b'));
     $this->assertTrue($this->redis->zRange('k', 0, -1, true) == array('b' => 1.0));
     // zRange
     $this->assertTrue($z === $this->redis->zRange('key', 0, -1));
     // zScore
     $this->assertTrue(0.0 === $this->redis->zScore('key', $z[0]));
     $this->assertTrue(1.0 === $this->redis->zScore('key', $z[1]));
     $this->assertTrue(2.0 === $this->redis->zScore('key', $z[2]));
     // zRank
     $this->assertTrue(0 === $this->redis->zRank('key', $z[0]));
     $this->assertTrue(1 === $this->redis->zRank('key', $z[1]));
     $this->assertTrue(2 === $this->redis->zRank('key', $z[2]));
     // zRevRank
     $this->assertTrue(2 === $this->redis->zRevRank('key', $z[0]));
     $this->assertTrue(1 === $this->redis->zRevRank('key', $z[1]));
     $this->assertTrue(0 === $this->redis->zRevRank('key', $z[2]));
     // zIncrBy
     $this->assertTrue(3.0 === $this->redis->zIncrBy('key', 1.0, $z[2]));
     $this->assertTrue(3.0 === $this->redis->zScore('key', $z[2]));
     $this->assertTrue(5.0 === $this->redis->zIncrBy('key', 2.0, $z[2]));
     $this->assertTrue(5.0 === $this->redis->zScore('key', $z[2]));
     $this->assertTrue(2.0 === $this->redis->zIncrBy('key', -3.0, $z[2]));
     $this->assertTrue(2.0 === $this->redis->zScore('key', $z[2]));
     // mset
     $a = array('k0' => 1, 'k1' => 42, 'k2' => NULL, 'k3' => FALSE, 'k4' => array('a' => 'b'));
     $this->assertTrue(TRUE === $this->redis->mset($a));
     foreach ($a as $k => $v) {
         $this->assertTrue($this->redis->get($k) === $v);
     }
     $a = array('k0' => 1, 'k1' => 42, 'k2' => NULL, 'k3' => FALSE, 'k4' => array('a' => 'b'));
     // hSet
     $this->redis->delete('key');
     foreach ($a as $k => $v) {
         $this->assertTrue(1 === $this->redis->hSet('key', $k, $v));
     }
     // hGet
     foreach ($a as $k => $v) {
         $this->assertTrue($v === $this->redis->hGet('key', $k));
     }
     // hGetAll
     $this->assertTrue($a === $this->redis->hGetAll('key'));
     $this->assertTrue(TRUE === $this->redis->hExists('key', 'k0'));
     $this->assertTrue(TRUE === $this->redis->hExists('key', 'k1'));
     $this->assertTrue(TRUE === $this->redis->hExists('key', 'k2'));
     $this->assertTrue(TRUE === $this->redis->hExists('key', 'k3'));
     $this->assertTrue(TRUE === $this->redis->hExists('key', 'k4'));
     // hMSet
     $this->redis->delete('key');
     $this->redis->hMSet('key', $a);
     foreach ($a as $k => $v) {
         $this->assertTrue($v === $this->redis->hGet('key', $k));
     }
     // hMget
     $hmget = $this->redis->hMget('key', array_keys($a));
     foreach ($hmget as $k => $v) {
         $this->assertTrue($v === $a[$k]);
     }
     // getMultiple
     $this->redis->set('a', NULL);
     $this->redis->set('b', FALSE);
     $this->redis->set('c', 42);
     $this->redis->set('d', array('x' => 'y'));
     $this->assertTrue(array(NULL, FALSE, 42, array('x' => 'y')) === $this->redis->getMultiple(array('a', 'b', 'c', 'd')));
     // pipeline
     $this->sequence(Redis::PIPELINE);
     // multi-exec
     $this->sequence(Redis::MULTI);
     // keys
     $this->assertTrue(is_array($this->redis->keys('*')));
     // issue #62, hgetall
     $this->redis->del('hash1');
     $this->redis->hSet('hash1', 'data', 'test 1');
     $this->redis->hSet('hash1', 'session_id', 'test 2');
     $data = $this->redis->hGetAll('hash1');
     $this->assertTrue($data['data'] === 'test 1');
     $this->assertTrue($data['session_id'] === 'test 2');
     // issue #145, serializer with objects.
     $this->redis->set('x', array(new stdClass(), new stdClass()));
     $x = $this->redis->get('x');
     $this->assertTrue(is_array($x));
     $this->assertTrue(is_object($x[0]) && get_class($x[0]) === 'stdClass');
     $this->assertTrue(is_object($x[1]) && get_class($x[1]) === 'stdClass');
     // revert
     $this->assertTrue($this->redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_NONE) === TRUE);
     // set ok
     $this->assertTrue($this->redis->getOption(Redis::OPT_SERIALIZER) === Redis::SERIALIZER_NONE);
     // get ok
 }
开发者ID:stonegithubs,项目名称:phpredis,代码行数:101,代码来源:TestRedis.php

示例9: hGetAll

 public function hGetAll($key)
 {
     return $this->connection->hGetAll($key);
 }
开发者ID:oat-sa,项目名称:generis,代码行数:4,代码来源:class.PhpRedisDriver.php

示例10: exit

    exit('error[01]');
}
# $ip_key = '58WB5PL2j7QuMDIwMzgxLjE0NDE1MDMyMDQ=';
/* 压测时用到的代码  S */
if ($debug && 0) {
    include '/www/dynamic/html/channel/mainpage/ip_cp_array.php';
    // $icNum = count($ipckArr);
    $icIndex = mt_rand(0, 1000);
    $ip_key = $specialIpCkArr1[$icIndex];
}
/* 压测时用到的代码 E */
## 全局变量声明
# 属性所对应的权重
$propertyArr = array('nproduct' => 1.0, 'nbooktitle' => 0.95, 'nmanu' => 0.85, 'ntype' => 0.78, 'nproperty' => 0.7, 'nsubcat' => 0.6, 'eng' => 0.6, 'n' => 0.3, 'nr' => 0.3, 'nz' => 0.3);
if ($ip_key) {
    $result = $redis->hGetAll($ip_key);
    //$key = '';
    $fields = 'document_id,title,url,pic_src';
    # 解析从redis过来的数据
    $newArr = array();
    foreach ($result as $key => $value) {
        $value = str_replace('(u', '(', $value);
        $value = str_replace(array('[(', ')]', '\'', '[', ']', '\\'), '', $value);
        $arr1 = explode('), (', trim($value, "'"));
        $res1_1 = array();
        foreach ($arr1 as $k2 => $v2) {
            $res1_1[$k2] = explode(', ', trim($v2, "'"));
        }
        $newArr[$key] = $res1_1;
    }
    # 从redis获得两组数据doc_id和domain  $newArr['article_id'] ; $newArr['domain']
开发者ID:suhanyujie,项目名称:myFavorite,代码行数:31,代码来源:guess_you_like.php

示例11: json_encode

}
if ($advertiser != '') {
    $arr[] = "1:" . $advertiser;
}
if ($adunit != '') {
    $arr[] = "2:" . $adunit;
}
$subpattern = "";
if (count($arr) != 0) {
    $subpattern = join("|", $arr);
}
$result = array();
while ($from < time()) {
    $date = gmdate($format, $from);
    if ($subpattern != '') {
        $key = $bucket . '|' . $date . '|' . $subpattern;
    } else {
        $key = $bucket . '|' . $date;
    }
    $hash = $redis->hGetAll($key);
    if ($hash) {
        $cost = $hash['1'];
        $revenue = $hash['2'];
        $impressions = $hash['3'];
        $clicks = $hash['4'];
        $result[] = array('timestamp' => $from * 1000, 'cost' => $cost, 'revenue' => $revenue, 'clicks' => $clicks, 'impressions' => $impressions);
    }
    $from += $incr;
}
array_pop($result);
print json_encode($result);
开发者ID:DT-Priyanka,项目名称:Malhar,代码行数:31,代码来源:json.php

示例12: 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

示例13: getJobStruct

 /**
  * 获取任务的结构体
  *
  * @param string $jobId
  * @return array
  */
 public function getJobStruct($jobId)
 {
     return $this->client->hGetAll($this->name . ':' . Job::JOB_TAB . ':' . $jobId);
 }
开发者ID:lezhizhe,项目名称:RedisQueue-as-like-beanstalkd,代码行数:10,代码来源:Queue.php

示例14: hashGet

 /**
  * 获取hash表的数据
  * @param $hash string 哈希表名
  * @param $key mixed 表中要存储的key名 默认为null 返回所有key->value
  * @param $type int 要获取的数据类型 0:返回所有key 1:返回所有value 2:返回所有key->value
  */
 public static function hashGet($hash, $key = array(), $type = 0)
 {
     $redis = new \Redis();
     $redis->connect(self::_HOST, self::_PORT);
     $return = null;
     if ($key) {
         if (is_array($key) && !empty($key)) {
             $return = $redis->hMGet($hash, $key);
         } else {
             $return = $redis->hGet($hash, $key);
         }
     } else {
         switch ($type) {
             case 0:
                 $return = $redis->hKeys($hash);
                 break;
             case 1:
                 $return = $redis->hVals($hash);
                 break;
             case 2:
                 $return = $redis->hGetAll($hash);
                 break;
             default:
                 $return = false;
                 break;
         }
     }
     $redis->close();
     $redis = null;
     return $return;
 }
开发者ID:skyshow,项目名称:ticket,代码行数:37,代码来源:MyRedis.class.php

示例15: split_line

header("cache-control:no-cache,must-revalidate");
header("Content-Type:text/html;charset=utf8");
function split_line($input, $separator)
{
    $ret = array();
    $line = strtok($input, $separator);
    while ($line != "") {
        array_push($ret, $line);
        $line = strtok($separator);
    }
    return $ret;
}
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
$deployment = $redis->get('deployment');
$machine_status = $redis->hGetAll('MachineStatus');
$outputstr = "{\"deployment\":{$deployment},\"machine_status\":[";
$first = true;
while (list($ip, $info) = each($machine_status)) {
    if ($first) {
        $first = false;
    } else {
        $outputstr = $outputstr + ",";
    }
    $outputstr = $outputstr . "{\"ip\":\"{$ip}\",\"status\":" . base64_decode($info) . "}";
}
$outputstr = $outputstr . "]}";
echo $outputstr;
?>

开发者ID:ifzz,项目名称:distri.lua,代码行数:29,代码来源:info.php


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