# 17.4.5 set类型

* ⽆序集合
* 元素为string类型
* 元素具有唯⼀性，不重复
* 说明：对于集合没有修改操作

增加

* 添加元素

sadd key member1 member2 ...

* 例1：向键'a3'的集合中添加元素'zhangsan'、'lisi'、'wangwu'

sadd a3 zhangsan sili wangwu

![Image](https://github.com/clay-wangzhi/wiki/tree/46b947765d64b8562206df9ac2bae98e26b90b86/17%20Redis/17.4%20数据库操作/images/df11040715a63f064757956a24c5d7df6f4bed53.png)

获取

* 返回所有的元素

smembers key

* 例2：获取键'a3'的集合中所有元素

smembers a3

![Image](https://github.com/clay-wangzhi/wiki/tree/46b947765d64b8562206df9ac2bae98e26b90b86/17%20Redis/17.4%20数据库操作/images/9ad9d7e260a7f33bf2d8ad74e1f4962dab096315.png)

删除

* 删除指定元素

srem key value

* 例3：删除键'a3'的集合中元素'wangwu'

srem a3 wangwu

![Image](https://github.com/clay-wangzhi/wiki/tree/46b947765d64b8562206df9ac2bae98e26b90b86/17%20Redis/17.4%20数据库操作/images/542cd7f4df873335ac556491b7c97b8450654e45.png)


---

# 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.5-set-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.
