redis-connections
This skill guides agents on configuring Redis clients efficiently through connection pooling or multiplexing, command pipelining, and proper timeout settings.
Identity proven by GitHub's verified organisation badge (redis)
- Agents
- Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode, claude.ai and API
- License
- MIT (permissive)
- Pin
- a84871dpinned Oct 9, 2026
- Context cost
- about 1,100 tokenswhen the skill loads
- GitHub stars
- 165on redis/agent-skills
- Scripts
- None found
What it does
“Redis client and connection guidance covering connection pooling, multiplexing, pipelining, client-side caching with RESP3, avoiding slow commands (KEYS, SMEMBERS, HGETALL), and tuning socket timeouts. Use when configuring a Redis client (redis-py, Jedis, Lettuce, NRedisStack), batching commands for throughput, eliminating per-request connection creation, iterating large keyspaces with SCAN, enabling client-side caching for read-heavy workloads, or setting connect and read timeouts.”
Generated summary from the skill's own text
This skill guides agents on configuring Redis clients efficiently through connection pooling or multiplexing, command pipelining, and proper timeout settings. It covers avoiding blocking operations, iterating large datasets with SCAN commands, and enabling client-side caching for frequently accessed data. The skill applies to redis-py, Jedis, Lettuce, go-redis, and NRedisStack clients.
When to use it
- Setting up a new Redis client in your application code
- Diagnosing latency from numerous small Redis operations
- Iterating over large keyspaces, sets, hashes, or lists
- Caching frequently read but rarely changed data locally
When not to
- Workloads with heavy write traffic where cache invalidation overhead exceeds benefits
- Using blocking commands like BLPOP on multiplexed connections
- Applications requiring strict per-request connection isolation
Install
These commands install from the publisher's repository and need no account.
skills CLI
npx skills add redis/agent-skills --skill redis-connectionsInstalls from the repository's default branch, which may have changed since the commit we checked.
GitHub CLI 2.90 or later
gh skill install redis/agent-skills redis-connections@a84871d065f398fed55e1633f66b66f731eb4e2bInstalls the commit we checked (a84871d).
Copy by hand
Download the folder at a84871d and put it in .claude/skills/redis-connections for Claude Code and in .agents/skills/redis-connections for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode.
Claude Code plugin
/plugin install redis-development@claude-plugins-officialThe publisher's plugin in Claude's official marketplace. It may hold more than this skill, and we have not pinned it.
Copy for your agent
A prompt for any coding agent. It installs this skill from GitHub at the pinned commit, copies the files as they are, and runs nothing unless you ask.
Prompt
Install the agent skill "redis-connections" by Redis. Source, pinned to commit a84871d065f398fed55e1633f66b66f731eb4e2b: https://github.com/redis/agent-skills/tree/a84871d065f398fed55e1633f66b66f731eb4e2b/plugins/redis-development/skills/redis-connections 1. Download that folder at exactly this commit. Do not use the default branch. 2. Copy every file unchanged, keeping the folder structure, into .claude/skills/redis-connections/ for Claude Code and .agents/skills/redis-connections/ for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode. Create the folders if they do not exist. 3. Do not edit the files, and do not run any script in the folder unless I ask you to. 4. When you are done, list the files you copied and where you put them. Listing and checks: https://www.agentnative.dev/skills/redis/redis-connections
SKILL.md at the pin
---
name: redis-connections
description: Redis client and connection guidance covering connection pooling, multiplexing, pipelining, client-side caching with RESP3, avoiding slow commands (KEYS, SMEMBERS, HGETALL), and tuning socket timeouts. Use when configuring a Redis client (redis-py, Jedis, Lettuce, NRedisStack), batching commands for throughput, eliminating per-request connection creation, iterating large keyspaces with SCAN, enabling client-side caching for read-heavy workloads, or setting connect and read timeouts.
license: MIT
metadata:
author: Redis, Inc.
version: "0.1.0"
---
# Redis Connections
Client-side guidance for talking to Redis efficiently: how to share connections, how to batch commands, which commands not to call in production, when to turn on client-side caching, and how to set timeouts that fail fast without breaking healthy traffic.
## When to apply
- Creating or reviewing a Redis client setup (redis-py, Jedis, Lettuce, go-redis, NRedisStack).
- Making many small Redis calls and wondering where the latency is going.
- Iterating large keyspaces, sets, hashes, or lists.
- Enabling client-side caching for hot keys.
- Tuning connect / read / write timeouts.
## 1. Pool or multiplex — never one connection per request
The single biggest mistake in Redis client code is opening a new TCP connection for every operation. Always either:
- **Pool** — keep N persistent connections that the application leases per call (redis-py `ConnectionPool`, Jedis `JedisPooled`, go-redis client).
- **Multiplex** — share a single connection across all requests (Lettuce, NRedisStack).
| Style | Used by | Note |
|---|---|---|
| Pool | redis-py, Jedis, go-redis | Each lease blocks if pool exhausted; size the pool to your concurrency |
| Multiplex | Lettuce, NRedisStack | Single connection; **cannot** carry blocking commands like `BLPOP` |
```python
# redis-py — connection pool
pool = redis.ConnectionPool(host="localhost", port=6379, max_connections=50)
r = redis.Redis(connection_pool=pool)
```
See [references/pooling.md](references/pooling.md) for Python + Java + Lettuce examples.
## 2. Pipeline bulk work
For N commands that don't depend on each other's results, send them as a single batch with pipelining. One round-trip instead of N.
```python
pipe = redis.pipeline()
for user_id in user_ids:
pipe.get(f"user:{user_id}")
results = pipe.execute()
```
Use **non-transactional** pipelining for performance, and `pipeline(transaction=True)` only when you actually need atomicity (see redis-core's transactions guidance).
See [references/pipelining.md](references/pipelining.md).
## 3. Avoid commands that scan everything
Anything that walks the whole keyspace (or a whole large container) blocks the server. Use incremental variants instead.
| Don't | Use |
|---|---|
| `KEYS pattern` | `SCAN` cursor loop |
| `SMEMBERS large_set` | `SSCAN` |
| `HGETALL large_hash` | `HSCAN` |
| `LRANGE 0 -1` on a huge list | Paginate (`LRANGE 0 100`) |
```python
cursor = 0
while True:
cursor, keys = redis.scan(cursor, match="user:*", count=100)
for key in keys:
process(key)
if cursor == 0:
break
```
**Blocking commands (`BLPOP`, `BRPOP`, `BLMOVE`) are different** — they intentionally wait for data and are fine for queue consumers, but always pass a timeout, and don't issue them on a multiplexed connection (Lettuce, NRedisStack).
See [references/blocking.md](references/blocking.md).
## 4. Client-side caching for hot keys
For data that's read often and written rarely (config, feature flags, sessions on every request), enable RESP3 client-side caching. The client keeps a local copy and the server invalidates it on writes — saving the round trip for hot reads.
```python
client = redis.Redis(
host="localhost",
port=6379,
protocol=3, # RESP3 is required
cache_config=redis.CacheConfig(max_size=1000),
)
```
Skip it for write-heavy workloads or data that changes constantly — the invalidation traffic overruns the savings.
See [references/client-cache.md](references/client-cache.md).
## 5. Set explicit timeouts
Defaults vary by client and may be too generous. Pick values that match the *application's* failure model:
```python
r = redis.Redis(
host="localhost",
socket_connect_timeout=2.0, # fail fast on dead nodes
socket_timeout=5.0, # tune to expected operation time
retry_on_timeout=True,
)
```
Rule of thumb: connect timeout shorter than read/write timeout. Tight timeouts + retry-on-timeout for latency-sensitive paths; longer timeouts for batch jobs.
See [references/timeouts.md](references/timeouts.md).
## References
- [Redis: Connection Pools and Multiplexing](https://redis.io/docs/latest/develop/clients/pools-and-muxing/)
- [Redis: Pipelining](https://redis.io/docs/latest/develop/use/pipelining/)
- [Redis: SCAN](https://redis.io/docs/latest/commands/scan/)
- [Redis: Client-side caching](https://redis.io/docs/latest/develop/clients/client-side-caching/)
- [Redis: Clients](https://redis.io/docs/latest/develop/clients/)
From redis/agent-skills at a84871d, shown as plain text under its license: MIT (permissive). The license text is in plugins/redis-development/skills/redis-connections/SKILL.md.
View SKILL.md on GitHub at a84871dFiles
- SKILL.md5.1 KB · ee6caf1b8c97
- references/
- blocking.md1.8 KB · 7238bac4df59
- client-cache.md2.0 KB · d63bb83f79e8
- pipelining.md1.1 KB · 3d248ffc53be
- pooling.md1.9 KB · 7e3332bca8cf
- timeouts.md1.4 KB · 8edd9334a419
6 files, 13 KB in total. Each file has a sha256 in the pin's manifest; the first 12 characters are shown.
Skill folder on GitHub at a84871dAlso in
The same SKILL.md content appears in these places too. We list it once and credit the oldest public source.
More from Redis
iris-development
This skill integrates with Redis Agent Memory, a managed service on Redis Cloud that provides persistent memory for AI agents.
Claude Code, Codex, Cursor +4 · about 970 tokens · pinned 6 days ago
redis-clustering
This skill guides agents on designing Redis Cluster keys using hash tags to avoid CROSSSLOT errors in multi-key operations, and on routing reads to replicas…
Claude Code, Codex, Cursor +4 · about 910 tokens · pinned 6 days ago
redis-core
This skill guides agents in designing Redis data models by selecting appropriate data structures (String, Hash, List, Set, Sorted Set, JSON, Stream, Vector…
Claude Code, Codex, Cursor +4 · about 640 tokens · pinned 6 days ago
redis-observability
This skill guides agents on monitoring Redis instances by identifying key metrics to track, using built-in diagnostic commands like SLOWLOG and MEMORY DOCTOR…
Claude Code, Codex, Cursor +4 · about 770 tokens · pinned 6 days ago
redis-search
This skill guides agents through Redis Search for building and querying search indexes on Hash or JSON documents.
Claude Code, Codex, Cursor +4 · about 2.7K tokens · pinned 6 days ago
redis-security
This skill guides hardening Redis deployments for production through authentication, ACL-based access control, TLS encryption, and network isolation.
Claude Code, Codex, Cursor +4 · about 780 tokens · pinned 6 days ago
Related in Backend and APIs
upstash-ratelimit-js
This skill adds rate limiting to serverless and edge applications using the Upstash Rate Limit TypeScript SDK backed by Upstash Redis.
by upstashCommunity
Claude Code, Codex, Cursor +4 · about 250 tokens · pinned 6 days ago
nvflare-orient
Routes NVFLARE requests to appropriate downstream skills based on user intent and preliminary source inspection findings.
by NVIDIAOfficial publisher
Claude Code, Codex, Cursor +4 · about 600 tokens · pinned 6 days ago
cloudflare-email-service
This skill enables agents to send transactional emails and route incoming emails using Cloudflare's Email Service platform.
by CloudflareOfficial publisher
Claude Code, Codex, Cursor +4 · about 1.6K tokens · pinned 6 days ago
durable-objects
Build and debug Cloudflare Durable Objects applications for stateful coordination and persistent storage on the edge.
by CloudflareOfficial publisher
Claude Code, Codex, Cursor +4 · about 1.5K tokens · pinned 6 days ago
workers-best-practices
This skill guides code review and development of Cloudflare Workers by applying best practices for production readiness.
by CloudflareOfficial publisher
Claude Code, Codex, Cursor +4 · about 1.3K tokens · pinned 6 days ago
supabase
This skill enables the agent to work with Supabase products including Database, Auth, Edge Functions, Realtime, Storage, and Vectors.
by SupabaseOfficial publisher
Claude Code, Codex, Cursor +4 · about 3.3K tokens · pinned 6 days ago