All skills
redis avatar

/redis-connections

@d3d89fa official
by redisredis/agent-skills163 stars
30

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.

Use this Skill: https://skilld.dev/gh/redis/agent-skills/redis-connections

This session only. Nothing lands on disk.

referencestimeouts.md

≈342 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Configure Connection Timeouts

Configure appropriate timeout values to improve your application's connection resilience. While most Redis clients set default timeouts, choosing well-tuned values based on your application's usage patterns leads to better failure recovery.

Correct: Set timeouts based on your application needs.

r = redis.Redis(
    host='localhost',
    socket_timeout=5.0,          # Read/write timeout - tune based on expected operation time
    socket_connect_timeout=2.0,  # Connection timeout - shorter for fast failure detection
    retry_on_timeout=True        # Automatic retry on timeout
)

Incorrect: Relying solely on defaults without considering your use case.

# Not ideal: Default timeouts may not match your application's needs
r = redis.Redis(host='localhost')

# For example, if your app needs fast failure detection,
# the default timeouts might be too generous

Considerations:

  • Set socket_connect_timeout shorter than socket_timeout for quick connection failure detection
  • For latency-sensitive apps, use tighter timeouts with retry logic
  • For batch operations, allow longer timeouts to complete large operations
  • Consider using health checks alongside timeouts for robust failure handling

Reference: Redis Client Configuration

Source: SKILL.md on GitHub

No alerts1mo3 checks · Risk SAFE
  • Gen Agent Trust Hub1mo

    This skill provides architectural guidance and code examples for Redis connection management, authored by Redis, Inc. It contains no malicious patterns or security risks.

  • Socket1mo

    No alerts

  • Snyk1mo

    Risk: LOW · No issues

Signed by skilld at d3d89fa. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 days ago.

Activeupdated 4 months ago
metadata
{
  "author": "Redis, Inc.",
  "version": "0.1.0"
}
  • redis
  • connection-pooling
  • pipelining
  • resp3
  • client-side-caching
  • timeouts
  • redis-py
  • jedis
  • lettuce
  • performance-tuning

README badge

README badge for redis/agent-skills/redis-connections

Provides patterns for configuring Redis clients to use connection pooling or multiplexing, pipelining bulk commands, avoiding blocking full-keyspace scans, enabling RESP3 client-side caching, and setting appropriate socket timeouts. Covers redis-py, Jedis, Lettuce, go-redis, and NRedisStack.

Generated from the current SKILL.md.

Which Redis clients does this skill cover?
It covers redis-py, Jedis, Lettuce, go-redis, and NRedisStack. The guidance applies to any client but examples are tailored to these libraries.
Does this skill explain how to use blocking commands like BLPOP?
Yes. It notes that blocking commands are fine for queue consumers but must always have a timeout set, and cannot be issued on a multiplexed connection (Lettuce, NRedisStack).
When should I enable client-side caching?
Enable it for read-heavy workloads with infrequent writes, like config, feature flags, or session data on every request. Skip it for write-heavy or frequently changing data, where invalidation traffic outweighs the savings.
What's the difference between connection pooling and multiplexing?
Pooling (redis-py, Jedis, go-redis) keeps multiple persistent connections that are leased per call and blocks if exhausted. Multiplexing (Lettuce, NRedisStack) shares a single connection across all requests and cannot carry blocking commands.
Why should I avoid the KEYS command in production?
KEYS scans the entire keyspace and blocks the server. Use SCAN with a cursor loop instead, or SSCAN/HSCAN for sets and hashes.

Generated from the current SKILL.md. These answers refresh after source changes.