Redis教程9-哈希(Hash)

Redis hash 是一个 string 类型的 field(字段) 和 value(值) 的映射表,hash 特别适合用于存储对象。

Redis 中每个 hash 可以存储 232 - 1 键值对(40多亿)。

实例

127.0.0.1:6379> hmset user name zhangsan age 30 tel 111222333 address chinese
OK
127.0.0.1:6379> hmget user name age address tel
1) "zhangsan"
2) "30"
3) "chinese"
4) "111222333"
127.0.0.1:6379>

在以上实例中,我们设置了 redis 的一些描述信息(name, age, tel, address) 到哈希表的 user中。

更多命令请参考:https://redis.io/commands

  • HDEL
  • HEXISTS
  • HGET
  • HGETALL
  • HINCRBY
  • HINCRBYFLOAT
  • HKEYS
  • HLEN
  • HMGET
  • HMSET
  • HSET
  • HSETNX
  • HVALS
  • HSCAN
原文地址:https://www.cnblogs.com/no-celery/p/13705478.html