redis/TEST.md

26 lines
982 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# redis 模块测试报告
## 测试场景
1. **基础操作 (TestBase)**:
- 验证 `GET`, `SET`, `DEL`, `EXISTS`, `GETSET` 等基本命令。
- 验证 `EXPIRE` 自动过期功能。
- 验证结构体自动序列化与反序列化。
- 验证 `MSET`, `MGET` 批量操作。
2. **泛型支持 (TestGenerics)**:
- 验证 `To[T]` 泛型函数对结果的反序列化。
3. **发布订阅 (TestSub)**:
- 验证 `Subscribe`, `Unsubscribe`, `PUBLISH` 功能。
- 验证并发订阅与取消订阅的稳定性。
## Benchmark 结果
```bash
goos: darwin
goarch: amd64
pkg: apigo.cc/go/redis
cpu: Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
BenchmarkGetSet-16 4057 283694 ns/op
BenchmarkIdMaker-16 338056 3377 ns/op
```
- `BenchmarkGetSet`: 每次 GET+SET 耗时约 283微秒受本地 Redis 响应速度影响)。
- `BenchmarkIdMaker`: 每次获取分布式 ID 耗时约 3.4微秒(得益于 100 步长的预取机制)。