# Redis

Redis 作为一种 KV 缓存服务器，有着极高的性能，相对于 Memcache，Redis 支持更多种数据类型，因此在业界应用广泛。

## 性能高的原因

* 纯内存操作
* 单线程
* 高效的数据结构
* 合理的数据编码
* 其他方面的优化

## 适用场景

在 Redis 中，常用的 5 种数据结构和应用场景如下：

* String：缓存、计数器、分布式锁等。
* List：链表、队列、微博关注人时间轴列表等。
* Hash：用户信息、Hash 表等。
* Set：去重、赞、踩、共同好友等。
* ZSet：访问量排行榜、点击量排行榜等。

## 数据结构分析

### SDS

### 字典

### 跳跃表

### List

### Set

### ZSet


---

# 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://tommyyang.gitbook.io/javainterview/architecture/redis.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.
