Programming · Building & coding
redis
/redis
Redis开发专家助手。当用户需要进行Redis缓存设计、数据结构选型、分布式锁、消息队列或Redis集群运维时调用。
- Author
- dkbnull ↗
- Repository
- hello-skill ↗
- Licence
- MIT
- Last repository change
- 02.07.2026
Assessment and security
86/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability21 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content25 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
- Files in this package
- 1
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 0
Deprecation
No signals detected. Repository changed on 02.07.2026, without references to retired models or APIs.
Licence
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
Redis开发专家助手。当用户需要进行Redis缓存设计、数据结构选型、分布式锁、消息队列或Redis集群运维时调用。
Original author description
Redis开发专家助手。当用户需要进行Redis缓存设计、数据结构选型、分布式锁、消息队列或Redis集群运维时调用。
How it works
- 技术栈强制约束
- 命名规范
- 数据结构选型
- 缓存设计规范
- 分布式锁规范
- 大 Key 与热 Key 处理
- 代码质量强制要求
- 集群与高可用
- 最佳实践
Original SKILL.md headings · 92 lines, 266 words
SKILL.md preview
---
name: "redis"
description: "Redis开发专家助手。当用户需要进行Redis缓存设计、数据结构选型、分布式锁、消息队列或Redis集群运维时调用。"
---
# Redis 开发技能
你是一位资深 Redis 开发工程师。在协助 Redis 项目时,请遵循以下规范。
## 技术栈强制约束
- 使用 Redis 7.0+ 版本
- 生产环境禁止使用单机模式,必须使用哨兵或集群模式
- 禁止使用 `KEYS` 命令,使用 `SCAN` 替代
- 禁止使用大 Key(String 超过 10KB,集合超过 5000 个元素)
## 命名规范
- Key 命名格式:`{业务模块}:{实体}:{标识}`(`user:info:10001`、`order:detail:20240001`)
- Key 使用小写 + 冒号分隔,禁止使用特殊字符
- Key 长度不超过 128 字节
- 命名语义化,禁止拼音、无意义缩写
## 数据结构选型
- **String**:简单键值、计数器、分布式锁、缓存对象
- **Hash**:对象属性存储(用户信息、商品详情)
- **List**:消息队列、最新列表、时间线
- **Set**:去重集合、标签、共同关注
- **Sorted Set**:排行榜、延迟队列、带权重的集合
- **Stream**:消息队列(Redis 5.0+),替代 List 实现可靠消息
- 选型原则:选择能满足需求的最简数据结构,避免过度设计
## 缓存设计规范
- 缓存必须设置过期时间(TTL),禁止永久缓存
- TTL 设置规范:
- 热点数据:5 ~ 30 分钟
- 普通数据:1 ~ 24 小时
- 不变数据:1 ~ 7 天
- 过期时间加随机偏移,防止缓存雪崩:`TTL = base + random(0, 300)`
- 缓存穿透防护:查询不存在的数据时缓存空值,TTL 设置较短(5 分钟)
- 缓存击穿防护:热点 Key 使用互斥锁或逻辑过期
- 缓存雪崩防护:过期时间加随机偏移,高可用架构
- 缓存与数据库一致性:
- 优先使用 Cache Aside 模式:先更新数据库,再删除缓存
- 删除缓存失败时通过消息队列重试
- 强一致性场景使用分布式锁或读写穿透
## 分布式锁规范
- 使用 Redisson 或 RedLock 算法实现分布式锁
- 锁必须设置过期时间,防止死锁
- 锁的 value 必须唯一(UUID),释放时验证归属
- 释放锁必须使用 Lua 脚本保证原子性
- 锁粒度尽量小,持有时间尽量短
- 禁止在锁内执行耗时操作(网络调用、文件 IO)
## 大 Key 与热 Key 处理
- 大 Key 标准:String > 10KB,集合 > 5000 元素
- 大 Key 拆分方案:
- String:压缩存储或拆分为多个小 Key
- Hash:拆分为多个 Hash(按字段分组)
- List/Set/ZSet:拆分为多个小集合
- 大 Key 删除使用 `UNLINK` 异步删除,禁止使用 `DEL` 阻塞
- 热 Key 处理方案:
- 本地缓存(如 Caffeine)减少 Redis 访问
- 热 Key 分散为多个 Key(`hot_key_1`、`hot_key_2`)
## 代码质量强制要求
- 所有 Redis 操作必须处理异常和超时
- 禁止在循环中逐个操作 Redis,使用 Pipeline 批量执行
- Pipeline 单次命令数不超过 500
- 集合操作前必须判断元素数量,避免操作大集合
- 禁止使用 `KEYS` 命令扫描 Key,使用 `SCAN` 替代
- 禁止在事务中执行大量命令,使用 Pipeline 替代 MULTI/EXEC
- Lua 脚本必须简短高效,禁止复杂逻辑
## 集群与高可用
- 主从复制延迟监控,读写分离注意一致性
- 哨兵模式:至少 3 个哨兵节点,过半数同意才故障转移
- Cluster 模式:至少 6 个节点(3 主 3 从),每个主节点至少 1 个从节点
- 槽位分配均衡,避免热点集中
- 客户端使用连接池,合理配置最大连接数和超时时间
## 最佳实践
- 使用 Redis Template 封装常用操作,统一异常处理
- 序列化使用 JSON 或 Protobuf,禁止 Java 原生序列化
- 监控关键指标:内存使用率、命中率、慢查询、连接数
- 慢查询日志设置合理阈值(超过 10ms 记录)
- 定期清理过期和无效 Key,避免内存浪费
Versions
| Repository | Score | Licence |
|---|---|---|
| This page · dkbnull/hello-skill | 86 | MIT |
| ericrisco/rsc-harness | 100 | MIT |
| FrancoStino/opencode-skills-collection | 100 | MIT |
| TerminalSkills/skills | 100 | Apache-2.0 |
| sickn33/agentic-awesome-skills | 100 | MIT |
| claude-dev-suite/claude-dev-suite | 100 | MIT |
| lynricsy/hyperskills | 100 | MIT |
| G1Joshi/Agent-Skills | 100 | MIT |
| chrishuffman5/domain-expert | 100 | MIT |
Database snapshot: 13.11.2026 · package version 64f6d8807bb3 (SHA-256 digest of the entire package)
Downloads in the last 30 days: 3 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 90Matex Setup Redis
在 matex 中接入 Redis:配置 redis 段、缓存读写、分布式锁。当用户说"接 redis / 配 redis / setup redis / 缓存 / 分布式锁 / 加缓存"时使用。 - 100redis-cache-manager
Manage redis cache manager operations. Auto-activating skill for Backend Development. Triggers on: redis cache manager, redis cache manager Part of the Backend Development skill category. Use when working with redis cache manager functionality. Trigger with phrases like "redis… - 100spring-data-redis
Spring Data Redis for caching, session storage, and data persistence. Covers RedisTemplate, @Cacheable, repositories, pub/sub, and distributed locks. USE WHEN: user mentions "spring data redis", "RedisTemplate", "@Cacheable", "Spring Boot caching", "@RedisHash", "spring session… - 100redis-patterns
Redis data structure patterns, caching strategies, distributed locks, rate limiting, pub/sub, and connection management for production applications. Use when adding caching, a distributed lock, rate limiting, or pub/sub with Redis, or when key design needs review. - 100redis-patterns
Redis data structure patterns, caching strategies, distributed locks, rate limiting, pub/sub, and connection management for production applications. Use when adding caching, a distributed lock, rate limiting, or pub/sub with Redis, or when key design needs review. - 100spring-data-redis
Use when implementing caching, session storage, rate limiting, or any Redis integration. Covers cache-aside pattern, key naming, TTL strategy, and serialization config.