获取所有哈希表中的字段

    1. <?php
    2. //连接本地的 Redis 服务
    3. $redis = new Redis();
    4. $redis->connect('10.1.3.15', 6379);
    5. $redis->auth('kuaicdn_redis_passwd');
    6. $redis->flushAll();
    7. $redis->hMSet('hast-test-hmset',array(
    8. 'key1'=>'StringValue',
    9. 'key2'=>256,
    10. 'key3'=>256.00002,
    11. ));
    12. $ret['cmd']=$redis->hKeys('hast-test-hmset');
    13. $ret['src']=$redis->hGetAll('hast-test-hmset');
    14. var_dump($ret);
    15. //print_r($ret);
    16. ?>

    输出:

    1. array(2) {
    2. ["cmd"]=>
    3. array(3) {
    4. [0]=>
    5. string(4) "key1"
    6. [1]=>
    7. string(4) "key2"
    8. [2]=>
    9. string(4) "key3"
    10. }
    11. ["src"]=>
    12. array(3) {
    13. ["key1"]=>
    14. string(11) "StringValue"
    15. ["key2"]=>
    16. string(3) "256"
    17. ["key3"]=>
    18. string(9) "256.00002"
    19. }
    20. }

    值得注意的是, key2 和 key3 输出为字符串类型了