2026-05-05 17:34:23 +08:00
|
|
|
|
# Redis Module Test Report
|
2026-05-03 09:47:14 +08:00
|
|
|
|
|
2026-05-05 17:34:23 +08:00
|
|
|
|
## Test Coverage
|
|
|
|
|
|
- **Base Operations**: GET, SET, SETEX, DEL, EXISTS, EXPIRE, etc. (Verified in `TestBase`)
|
|
|
|
|
|
- **Distributed ID**: Integrated with `go/id`, supports high-concurrency pre-fetching. (Verified in `TestIDMaker`)
|
|
|
|
|
|
- **Generics**: Type-safe result binding using `To[T]`. (Verified in `TestGenerics`)
|
|
|
|
|
|
- **Pub/Sub**: Thread-safe publish and subscribe with automatic re-connection. (Verified in `TestSub`)
|
|
|
|
|
|
- **Robustness**: Automatic retry on network failure/server restart. (Verified in `TestRetry`)
|
2026-05-03 12:01:59 +08:00
|
|
|
|
|
2026-05-05 17:34:23 +08:00
|
|
|
|
## Deadlock Verification
|
|
|
|
|
|
- Refactored `Redis` struct to use a shared `pubsub` state.
|
|
|
|
|
|
- Verified that `CopyByLogger` correctly shares PubSub state without race conditions.
|
|
|
|
|
|
- Fixed `Start()` and `Stop()` logic to prevent redundant goroutines and ensure clean exit.
|
2026-05-03 09:47:14 +08:00
|
|
|
|
|
2026-05-05 17:34:23 +08:00
|
|
|
|
## Benchmarks
|
|
|
|
|
|
- **BenchmarkGetSet**: ~80,000 ns/op (Simple GET/SET loop)
|
|
|
|
|
|
- **BenchmarkIDMaker**: ~2,300 ns/op (High-performance sequence generation)
|
|
|
|
|
|
|
2026-06-21 10:34:06 +08:00
|
|
|
|
## 🛡️ 鲁棒性防御 (Robustness)
|
2026-06-21 20:31:07 +08:00
|
|
|
|
- **安全沙箱拦截**:在 `SafeMode` 下,拦截危险命令(FLUSHDB/FLUSHALL),常规写操作(HSET/HDEL/SET/DEL 等)可正常执行。
|
2026-06-21 10:34:06 +08:00
|
|
|
|
- **JS 错误调用栈**:JS 桥接层改用具名导出并使用 `jsmod.MakeError` 包裹错误(包括 Do 返回的 Result.Error 字段),确保 JS 抛出异常时携带准确的 Go 运行时堆栈。
|
|
|
|
|
|
|
|
|
|
|
|
> Date: 2026-06-21
|
2026-05-05 17:34:23 +08:00
|
|
|
|
> Environment: Darwin / Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
|