--- tags: [redis, sliding-window, sorted-set, performance, monitoring] create time: 2026-06-01 10:30 --- # 滑动窗口日志方案细节 ## 概述 滑动窗口日志方案是最精确的限流方式:每条请求作为 Sorted Set 的一条记录,通过范围查询实现精确统计。这一节深入你标记为薄弱的 F6——Lua 脚本中的清理逻辑和各操作的详细时序。 ## 一、核心流程(F6 考点深挖) ### 完整时序图 ```mermaid sequenceDiagram participant App as Go 应用 participant R as Redis Note over App,R: ── Lua 脚本执行(原子化)─ App->>R: EVALSHA sha1 ...