Latest web development tutorials

Redis Hvals 命令

Redis哈希(Hash)

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

語法

redis Hvals 命令基本語法如下:

redis 127.0.0.1:6379> HVALS KEY_NAME FIELD VALUE 

可用版本

>= 2.0.0

返回值

一個包含哈希表中所有值的表。 當key 不存在時,返回一個空表。

實例

redis 127.0.0.1:6379> HSET myhash field1 "foo"
(integer) 1
redis 127.0.0.1:6379> HSET myhash field2 "bar"
(integer) 1
redis 127.0.0.1:6379> HVALS myhash
1) "foo"
2) "bar"

# 空哈希表/不存在的key

redis 127.0.0.1:6379> EXISTS not_exists
(integer) 0

redis 127.0.0.1:6379> HVALS not_exists
(empty list or set)

Redis哈希(Hash)