redis-development
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRedis Best Practices
Redis 最佳实践
Comprehensive performance optimization guide for Redis, including Redis Query Engine, vector search, and semantic caching. Contains 29 rules across 11 categories, prioritized by impact to guide automated optimization and code generation.
一份全面的Redis性能优化指南,涵盖Redis Query Engine、向量搜索和语义缓存。包含11个类别下的29条规则,按影响优先级排序,可指导自动化优化与代码生成。
When to Apply
适用场景
Reference these guidelines when:
- Designing Redis data models and key structures
- Implementing caching, sessions, or real-time features
- Using Redis Query Engine (FT.CREATE, FT.SEARCH, FT.AGGREGATE)
- Building vector search or RAG applications with RedisVL
- Implementing semantic caching with LangCache
- Optimizing Redis performance and memory usage
在以下场景中参考本指南:
- 设计Redis数据模型与键结构
- 实现缓存、会话或实时功能
- 使用Redis Query Engine(FT.CREATE、FT.SEARCH、FT.AGGREGATE)
- 借助RedisVL构建向量搜索或RAG应用
- 使用LangCache实现语义缓存
- 优化Redis性能与内存使用
Rule Categories by Priority
按优先级划分的规则类别
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Data Structures & Keys | HIGH | |
| 2 | Memory & Expiration | HIGH | |
| 3 | Connection & Performance | HIGH | |
| 4 | JSON Documents | MEDIUM | |
| 5 | Redis Query Engine | HIGH | |
| 6 | Vector Search & RedisVL | HIGH | |
| 7 | Semantic Caching | MEDIUM | |
| 8 | Streams & Pub/Sub | MEDIUM | |
| 9 | Clustering & Replication | MEDIUM | |
| 10 | Security | HIGH | |
| 11 | Observability | MEDIUM | |
| 优先级 | 类别 | 影响程度 | 前缀 |
|---|---|---|---|
| 1 | 数据结构与键 | 高 | |
| 2 | 内存与过期策略 | 高 | |
| 3 | 连接与性能 | 高 | |
| 4 | JSON文档 | 中 | |
| 5 | Redis Query Engine | 高 | |
| 6 | 向量搜索与RedisVL | 高 | |
| 7 | 语义缓存 | 中 | |
| 8 | 流与发布/订阅 | 中 | |
| 9 | 集群与复制 | 中 | |
| 10 | 安全 | 高 | |
| 11 | 可观测性 | 中 | |
Quick Reference
快速参考
1. Data Structures & Keys (HIGH)
1. 数据结构与键(高优先级)
- - Choose the Right Data Structure
data-choose-structure - - Use Consistent Key Naming Conventions
data-key-naming
- - 选择合适的数据结构
data-choose-structure - - 使用一致的键命名规范
data-key-naming
2. Memory & Expiration (HIGH)
2. 内存与过期策略(高优先级)
- - Configure Memory Limits and Eviction Policies
ram-limits - - Set TTL on Cache Keys
ram-ttl
- - 配置内存限制与淘汰策略
ram-limits - - 为缓存键设置TTL
ram-ttl
3. Connection & Performance (HIGH)
3. 连接与性能(高优先级)
- - Avoid Slow Commands in Production
conn-blocking - - Use Pipelining for Bulk Operations
conn-pipelining - - Use Connection Pooling or Multiplexing
conn-pooling - - Configure Connection Timeouts
conn-timeouts
- - 生产环境中避免使用慢命令
conn-blocking - - 批量操作使用流水线技术
conn-pipelining - - 使用连接池或多路复用
conn-pooling - - 配置连接超时
conn-timeouts
4. JSON Documents (MEDIUM)
4. JSON文档(中优先级)
- - Use JSON Paths for Partial Updates
json-partial-updates - - Choose JSON vs Hash Appropriately
json-vs-hash
- - 使用JSON路径进行部分更新
json-partial-updates - - 合理选择JSON与哈希结构
json-vs-hash
5. Redis Query Engine (HIGH)
5. Redis Query Engine(高优先级)
- - Use DIALECT 2 for Query Syntax
rqe-dialect - - Choose the Correct Field Type
rqe-field-types - - Index Only Fields You Query
rqe-index-creation - - Manage Indexes for Zero-Downtime Updates
rqe-index-management - - Write Efficient Queries
rqe-query-optimization
- - 使用DIALECT 2查询语法
rqe-dialect - - 选择正确的字段类型
rqe-field-types - - 仅为查询字段创建索引
rqe-index-creation - - 管理索引以实现零停机更新
rqe-index-management - - 编写高效查询语句
rqe-query-optimization
6. Vector Search & RedisVL (HIGH)
6. 向量搜索与RedisVL(高优先级)
- - Choose HNSW vs FLAT Based on Requirements
vector-algorithm-choice - - Use Hybrid Search for Better Results
vector-hybrid-search - - Configure Vector Indexes Properly
vector-index-creation - - Implement RAG Pattern Correctly
vector-rag-pattern
- - 根据需求选择HNSW或FLAT算法
vector-algorithm-choice - - 使用混合搜索提升结果质量
vector-hybrid-search - - 正确配置向量索引
vector-index-creation - - 正确实现RAG模式
vector-rag-pattern
7. Semantic Caching (MEDIUM)
7. 语义缓存(中优先级)
- - Configure Semantic Cache Properly
semantic-cache-best-practices - - Use LangCache for LLM Response Caching
semantic-cache-langcache-usage
- - 正确配置语义缓存
semantic-cache-best-practices - - 使用LangCache缓存LLM响应
semantic-cache-langcache-usage
8. Streams & Pub/Sub (MEDIUM)
8. 流与发布/订阅(中优先级)
- - Choose Streams vs Pub/Sub Appropriately
stream-choosing-pattern
- - 合理选择流或发布/订阅模式
stream-choosing-pattern
9. Clustering & Replication (MEDIUM)
9. 集群与复制(中优先级)
- - Use Hash Tags for Multi-Key Operations
cluster-hash-tags - - Use Read Replicas for Read-Heavy Workloads
cluster-read-replicas
- - 多键操作使用哈希标签
cluster-hash-tags - - 读密集型工作负载使用只读副本
cluster-read-replicas
10. Security (HIGH)
10. 安全(高优先级)
- - Use ACLs for Fine-Grained Access Control
security-acls - - Always Use Authentication in Production
security-auth - - Secure Network Access
security-network
- - 使用ACLs实现细粒度访问控制
security-acls - - 生产环境中始终启用认证
security-auth - - 保障网络访问安全
security-network
11. Observability (MEDIUM)
11. 可观测性(中优先级)
- - Use Observability Commands for Debugging
observe-commands - - Monitor Key Redis Metrics
observe-metrics
- - 使用可观测性命令进行调试
observe-commands - - 监控关键Redis指标
observe-metrics
How to Use
使用方法
Read individual rule files for detailed explanations and code examples:
rules/rqe-index-creation.md
rules/vector-rag-pattern.mdEach rule file contains:
- Brief explanation of why it matters
- Incorrect example with explanation
- Correct example with explanation
- Additional context and references
阅读单个规则文件获取详细说明与代码示例:
rules/rqe-index-creation.md
rules/vector-rag-pattern.md每个规则文件包含:
- 规则重要性的简要说明
- 错误示例及解释
- 正确示例及解释
- 额外背景信息与参考资料
Full Compiled Document
完整编译文档
For the complete guide with all rules expanded:
AGENTS.md如需查看包含所有扩展规则的完整指南,请参考:
AGENTS.md