# 17.4.3 hash类型

hash⽤于存储对象 对象的结构为属性、值 值的类型为string

## 增加、修改

* 设置单个属性

  ```
  hset key field value
  ```
* 设置多个属性

  ```
  hmset key field1 value1 field2 value2 ...
  ```

## 获取

* 获取指定键所有的属性

  ```
  hkeys key
  ```
* 获取⼀个属性的值

  ```
  hget key field
  ```
* 获取多个属性的值

  ```
  hmget key field1 field2 ...
  ```
* 获取所有属性的值

  ```
  hvals key
  ```
* 获取一个hash有多少个属性

  ```
  hlen key
  ```

## 删除

* 删除整个hash键及值，使⽤del命令
* 删除属性，属性对应的值会被⼀起删除

  ```
  hdel key field1 field2 ...
  ```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wiki.clay-wangzhi.com/17-redis/17.4-shu-ju-ku-cao-zuo/17.4.3-hash-lei-xing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
