redis hash 命令


HSET hash field value
HGET hash field


# 单个field设置  hset 
hset king id 1

# 获取单个filed的值
hget king id


# 注意:
# 且仅当域 field 尚未存在于哈希表的情况下, 将它的值设置为 value
# 这个不像setnx 根据key,这里是field
# 通俗讲就是field不存在的时候,才执行,存在不执行
# hash如果不存在,会自动创建
HSETNX hash field value


# 判断某个filed是否在该hash中存在
HEXISTS hash field

# 删除多个field
HDEL hash field [field …]

HMSET hash field value [field value …]
# 设置hash的多个field
hmset map one 1 two 2 three 3


HMGET hash field [field …]
hmget map one two five

# 返回hash中的所有field
HKEYS hash

# 返回该hash中的所有value 重复的值 会返回多条
HVALS hash

# 返回hash中的field的数量
HLEN key
# 返回哈希表key中,所有的域和值
HGETALL key

#filed值的长度
HSTRLEN hash field
# hash的某个field 加increment
HINCRBY hash field increment


# hash的某个field 加浮点数increment
# hincrbyfloat map five 0.5
HINCRBYFLOAT hash field increment
发布了506 篇原创文章 · 获赞 41 · 访问量 21万+

猜你喜欢

转载自blog.csdn.net/kq1983/article/details/104235938