redis-connections

Configure Redis clients with connection pooling, pipelining, client-side caching, and timeouts.

3|1|Updated Nov 30, 2025
One-click install
npx skills add https://github.com/PALabs-v1/AI_friend --skill redis-connections-palabs-v1
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: redis-connections
Source: https://github.com/PALabs-v1/AI_friend/tree/main/.claude/skills/redis-connections
Command: npx skills add https://github.com/PALabs-v1/AI_friend --skill redis-connections-palabs-v1

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Redis client code often suffers from per-request connection creation, N+1 round trips, blocking commands that stall the server, and poorly tuned timeouts. This Skill provides concrete guidance for configuring Redis clients efficiently across redis-py, Jedis, Lettuce, go-redis, and NRedisStack. ## Core Features & Use Cases - Connection Pooling & Multiplexing: Reuse persistent connections via pools (redis-py, Jedis, go-redis) or a single multiplexed connection (Lettuce, NRedisStack) instead of opening a new TCP connection per request. - Pipelining & Safe Iteration: Batch independent commands into one round trip with pipelines, and replace blocking commands like KEYS, SMEMBERS, and HGETALL with incremental SCAN, SSCAN, and HSCAN cursor loops. - Client-Side Caching & Timeouts: Enable RESP3 client-side caching for read-heavy hot keys, and set explicit connect and read timeouts matched to the application's failure model. - Use Case: When reviewing a Python service that creates a new redis.Redis() instance per request and calls KEYS in a loop, apply this Skill to introduce a ConnectionPool, pipeline the bulk reads, and switch to SCAN-based iteration. ## Quick Start Review my Redis client setup and rewrite it to use a connection pool, pipeline the batch reads, replace KEYS with SCAN, and set explicit socket timeouts.

Frequently Asked Questions about redis-connections

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up Redis connection pooling in Python?

Create a redis.ConnectionPool with host, port, and max_connections, then pass it to redis.Redis via the connection_pool argument. The pool reuses persistent connections across requests instead of opening a new TCP connection per call.

How to batch multiple Redis commands into one round trip?

Use pipelining: create a pipeline object, queue commands on it, then call execute to send them as a single batch. Use non-transactional pipelining for performance and transaction=True only when atomicity is required.

What is the difference between Redis connection pooling and multiplexing?

Pooling keeps multiple persistent connections leased per call, used by redis-py, Jedis, and go-redis. Multiplexing shares one connection across all requests, used by Lettuce and NRedisStack, but cannot carry blocking commands like BLPOP.

Why should I avoid the Redis KEYS command in production?

KEYS scans the entire keyspace and blocks the server on large datasets. Use SCAN with a cursor and match pattern instead, and similarly replace SMEMBERS with SSCAN and HGETALL with HSCAN for large containers.

When should I enable Redis client-side caching?

Enable it for data read frequently but written rarely, such as config, feature flags, or session data, using RESP3 protocol with a CacheConfig. Skip it for write-heavy workloads since invalidation traffic outweighs the savings.

Can I use blocking commands like BLPOP with Lettuce or NRedisStack?

No. Multiplexed clients share a single connection, so a blocking command would stall all callers. Use blocking commands only on pooled connections, and always pass a timeout such as BLPOP with timeout=5.