同时将多个 field-value (域-值)对设置到哈希表 key 中。

    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['src']=$redis->hGetAll('hast-test-hmset');
    13. print_r($ret);
    14. ?>

    返回值:

    1. Array
    2. (
    3. [src] => Array
    4. (
    5. [key1] => StringValue
    6. [key2] => 256
    7. [key3] => 256.00002
    8. )
    9. )