可以理解为python 的类
python伪代码 class 类: key=value key=value 访问里面的value是不是要先类().key redis的hash一样
hset key field value 例1 :设置key为person field 为name value为itcast 127.0.0.1:6379> hset person name itcast (integer) 1
hget key field 例1 :获取key为person field 为name的值 127.0.0.1:6379> hget person name "itcast"
hmset key field value field value ... 例1 :设置key为person field 为age value为14 address beijin 127.0.0.1:6379> hmset person age 14 address beijin OK
hmget key field field ... 例1 :获取key为person field 为name、age、address 127.0.0.1:6379> hmget person name age address 1) "itcast" 2) "14" 3) "beijin"
hgetall key 例1 :获取key为person所有数据 127.0.0.1:6379> hgetall person 1) "name" 2) "itcast" 3) "age" 4) "14" 5) "address" 6) "beijin"
hkeys key 例1 :获取key为person所有field 127.0.0.1:6379> hkeys person 1) "name" 2) "age" 3) "address"
hvals key 例1 :获取key为person所有value 127.0.0.1:6379> hvals person 1) "itcast" 2) "14" 3) "beijin"
hdel key field 例1 :删除key为person field为name 127.0.0.1:6379> hdel person name (integer) 1 127.0.0.1:6379> hgetall person 1) "age" 2) "14" 3) "address" 4) "beijin"
del key 例1 :删除key为person 127.0.0.1:6379> del person (integer) 1 127.0.0.1:6379> hgetall person (empty list or set)
和设置一样
例1 :更新key为person的age为18 127.0.0.1:6379> hmset person name itcast age 14 OK 127.0.0.1:6379> hgetall person 1) "name" 2) "itcast" 3) "age" 4) "14" 127.0.0.1:6379> hset person age 18 (integer) 0 127.0.0.1:6379> hgetall person 1) "name" 2) "itcast" 3) "age" 4) "18"