// hset/hget 存取hash表的数据 ~~~ $redis->hset('test:hash1', 'field1', 'v1'); $redis->hset('test:hash1', 'field2', 'v2'); $redis->hget('test:hash1', 'field1'); ~~~ // 只有在字段 field 不存在时,设置哈希表字段的值 ~~~ $redis->hsetnx('test:hash1', 'field1', 'v2'); $redis->hsetnx('test:hash1', 'field3', 'v3'); ~~~ // hmset/hmget 存取多个元素 ~~~ $redis->hmset('test:hash1', array('field3' => 'v3-2', 'field4' => 'v4')); $redis->hmget('test:hash1', array('field3','field4')); ~~~ // hincrby 指定字段,设置整数增量 ~~~ $redis->hincrby('test:hash1', 'field5', 3); $redis->hincrby('test:hash1', 'field6', -10); ~~~ // hexists 查询特定哈希表中,指定field的元素是否存在 ~~~ $redis->hexists('test:hash1', 'field1'); ~~~ // hdel 删除hash表中指定field的元素 ~~~ $redis->hdel('test:hash1', 'field2'); ~~~ // hlen 返回hash表元素个数 ~~~ $redis->hlen('test:hash1'); ~~~ // hkeys 返回hash表中的所有key ~~~ $redis->hkeys('test:hash1'); ~~~ // hvals 返回hash表中的所有value ~~~ $redis->hvals('test:hash1'); ~~~ // hgetall 返回整个hash表元素 ~~~ $redis->hgetall('test:hash1'); ~~~