Redis Hvals 命令


Redis Hvals 命令返回哈希表所有字段的值。

语法

redis Hvals 命令基本语法如下:

  1. redis 127.0.0.1:6379> HVALS KEY_NAME FIELD VALUE

可用版本

>= 2.0.0

返回值

一个包含哈希表中所有值的表。 当 key 不存在时,返回一个空表。

实例

  1. redis 127.0.0.1:6379> HSET myhash field1 "foo"
  2. (integer) 1
  3. redis 127.0.0.1:6379> HSET myhash field2 "bar"
  4. (integer) 1
  5. redis 127.0.0.1:6379> HVALS myhash
  6. 1) "foo"
  7. 2) "bar"
  8.  
  9. # 空哈希表/不存在的key
  10.  
  11. redis 127.0.0.1:6379> EXISTS not_exists
  12. (integer) 0
  13.  
  14. redis 127.0.0.1:6379> HVALS not_exists
  15. (empty list or set)