home / skills / redis / agent-skills / redis-development

redis-development skill

/skills/redis-development

This skill helps you optimize Redis performance and data models across RQE, vector search, and semantic caching for faster, cost-efficient apps.

npx playbooks add skill redis/agent-skills --skill redis-development

Review the files below or copy the command above to add this skill to your agents.

Files (36)
SKILL.md
4.0 KB
---
name: redis-development
description: Redis performance optimization and best practices. Use this skill when working with Redis data structures, Redis Query Engine (RQE), vector search with RedisVL, semantic caching with LangCache, or optimizing Redis performance.
license: MIT
metadata:
  author: redis
  version: "1.0.0"
---

# Redis Best Practices

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.

## 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

## Rule Categories by Priority

| Priority | Category | Impact | Prefix |
|----------|----------|--------|--------|
| 1 | Data Structures & Keys | HIGH | `data-` |
| 2 | Memory & Expiration | HIGH | `ram-` |
| 3 | Connection & Performance | HIGH | `conn-` |
| 4 | JSON Documents | MEDIUM | `json-` |
| 5 | Redis Query Engine | HIGH | `rqe-` |
| 6 | Vector Search & RedisVL | HIGH | `vector-` |
| 7 | Semantic Caching | MEDIUM | `semantic-cache-` |
| 8 | Streams & Pub/Sub | MEDIUM | `stream-` |
| 9 | Clustering & Replication | MEDIUM | `cluster-` |
| 10 | Security | HIGH | `security-` |
| 11 | Observability | MEDIUM | `observe-` |

## Quick Reference

### 1. Data Structures & Keys (HIGH)

- `data-choose-structure` - Choose the Right Data Structure
- `data-key-naming` - Use Consistent Key Naming Conventions

### 2. Memory & Expiration (HIGH)

- `ram-limits` - Configure Memory Limits and Eviction Policies
- `ram-ttl` - Set TTL on Cache Keys

### 3. Connection & Performance (HIGH)

- `conn-blocking` - Avoid Slow Commands in Production
- `conn-pipelining` - Use Pipelining for Bulk Operations
- `conn-pooling` - Use Connection Pooling or Multiplexing
- `conn-timeouts` - Configure Connection Timeouts

### 4. JSON Documents (MEDIUM)

- `json-partial-updates` - Use JSON Paths for Partial Updates
- `json-vs-hash` - Choose JSON vs Hash Appropriately

### 5. Redis Query Engine (HIGH)

- `rqe-dialect` - Use DIALECT 2 for Query Syntax
- `rqe-field-types` - Choose the Correct Field Type
- `rqe-index-creation` - Index Only Fields You Query
- `rqe-index-management` - Manage Indexes for Zero-Downtime Updates
- `rqe-query-optimization` - Write Efficient Queries

### 6. Vector Search & RedisVL (HIGH)

- `vector-algorithm-choice` - Choose HNSW vs FLAT Based on Requirements
- `vector-hybrid-search` - Use Hybrid Search for Better Results
- `vector-index-creation` - Configure Vector Indexes Properly
- `vector-rag-pattern` - Implement RAG Pattern Correctly

### 7. Semantic Caching (MEDIUM)

- `semantic-cache-best-practices` - Configure Semantic Cache Properly
- `semantic-cache-langcache-usage` - Use LangCache for LLM Response Caching

### 8. Streams & Pub/Sub (MEDIUM)

- `stream-choosing-pattern` - Choose Streams vs Pub/Sub Appropriately

### 9. Clustering & Replication (MEDIUM)

- `cluster-hash-tags` - Use Hash Tags for Multi-Key Operations
- `cluster-read-replicas` - Use Read Replicas for Read-Heavy Workloads

### 10. Security (HIGH)

- `security-acls` - Use ACLs for Fine-Grained Access Control
- `security-auth` - Always Use Authentication in Production
- `security-network` - Secure Network Access

### 11. Observability (MEDIUM)

- `observe-commands` - Use Observability Commands for Debugging
- `observe-metrics` - Monitor Key Redis Metrics

## How to Use

Read individual rule files for detailed explanations and code examples:

```
rules/rqe-index-creation.md
rules/vector-rag-pattern.md
```

Each rule file contains:
- Brief explanation of why it matters
- Incorrect example with explanation
- Correct example with explanation
- Additional context and references

## Full Compiled Document

For the complete guide with all rules expanded: `AGENTS.md`

Overview

This skill provides practical Redis performance optimization and best-practice guidance for development teams. It consolidates prioritized rules across data modeling, memory management, query optimization, vector search, and semantic caching. Use it to make targeted, high-impact improvements to Redis-based applications and to avoid common production pitfalls.

How this skill works

I inspect typical Redis usage patterns and recommend concrete changes: right data structures, key naming, TTL strategies, connection handling, and index configuration for the Redis Query Engine. The skill includes focused advice for vector search (RedisVL) and semantic caching with LangCache, plus security and observability checks. Each rule is prioritized by impact so you can apply high-value fixes first.

When to use it

  • Designing data models, key namespaces, or choosing Redis data types.
  • Implementing caching layers, session stores, or real-time features.
  • Building RQE-based queries and managing FT.CREATE/FT.SEARCH/FT.AGGREGATE indexes.
  • Developing vector search or RAG applications with RedisVL.
  • Adding semantic caching for LLM responses using LangCache.
  • Tuning production Redis for memory, latency, and connection performance.

Best practices

  • Choose the smallest, semantically correct data structure (string, hash, list, set, zset, JSON) for each use case to minimize memory and CPU.
  • Apply consistent key naming and TTL policies; set TTLs for cache keys and use eviction policies with configured memory limits.
  • Avoid blocking commands in hot paths; use pipelining, connection pooling or multiplexing and tune timeouts.
  • Index only fields you query in RQE, use DIALECT 2, and plan zero-downtime index updates.
  • For vectors, pick HNSW vs FLAT based on latency and accuracy needs; use hybrid search when combining embeddings with metadata.
  • Enforce ACLs, authentication, secure network access, and monitor Redis metrics and command patterns for anomalies.

Example use cases

  • Converting a cache built from large JSON blobs into compact hashes or selective JSON fields with TTLs to reduce RAM.
  • Rewriting slow aggregation queries using RQE best practices and selective indexing to cut query latency.
  • Configuring a LangCache layer to cache LLM outputs with semantic keys and appropriate eviction habits.
  • Choosing HNSW index parameters for a production vector search to balance recall and storage footprint.
  • Implementing connection pooling and pipelining for a bulk import job to minimize round-trips and timeouts.

FAQ

Which rules should I apply first?

Start with high-impact categories: data structures & keys, memory & expiration, and connection & performance. Small changes in these areas often yield the largest gains.

How do I decide between JSON and Hash?

Use JSON when you need nested documents and JSONPath updates; prefer Hashes for flat, high-cardinality fields to save memory and enable efficient partial updates.