09 Appendix More Dictionary Operation Commands #
Insert one or more elements #
Syntax: hmset key field value [field value …] Example:
127.0.0.1:6379> hmset myhash k1 val1 k2 val2
OK
127.0.0.1:6379> hmget myhash k1 k2
1) "val1"
2) "val2"
Query one or more elements #
Syntax: hmget key field [field …] Example:
127.0.0.1:6379> hmget myhash k1 k2
1) "v1"
2) "v2"
Query all fields of a key #
Syntax: hkeys key Example:
127.0.0.1:6379> hkeys myhash
1) "key1"
2) "key2"
Query all values of a key #
Syntax: hvals key Example:
127.0.0.1:6379> hvals myhash
1) "value1"
2) "value2"
Query all fields and values of a key #
Syntax: hgetall key Example:
127.0.0.1:6379> hgetall myhash
1) "k1"
2) "v1"
3) "k2"
4) "v2"
Accumulative calculation of a floating-point value #
Syntax: hincrbyfloat key field increment Example:
127.0.0.1:6379> hincrbyfloat myhash k3 2.2
"9.2"
Check if an element exists #
Syntax: hexists key field Example:
127.0.0.1:6379> hexists myhash key1
(integer) 1
Query the number of elements #
Syntax: hlen key Example:
127.0.0.1:6379> hlen myhash
(integer) 2