hash命令

什么是hash ? 在网上找了好久都没找到简截有力的说明。hash 我把它当成是集合,一个hash 就是一个集合,里面字段对应一个元素,元素不重复,字段都不一样。
简单hash 命令
1、hset 哈希名 字段 值 (设置hash 一次只设置一个字段)
hset hash_name field "one"
2、hget 哈希名 字段 (获取hash字段对应值)
hget hash_name field
3、hgetall 哈希名 (获取整个hash返回字段和值)
hgetall hash_name
4、hmset 哈希名 字段1 值 字段 2 值 ... (设置多个字段)
hmset hash_name fields1 "one" fields2 "two"
5、hmget 哈希名 字段 (可获取字段对应值的数据)
hmget hash_name fields3

  

原文地址:https://www.cnblogs.com/zc123/p/5888915.html