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.

referencespipelining.md

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

Use Pipelining for Bulk Operations

Batch multiple commands into a single round trip to reduce network latency.

Correct: Use pipeline for multiple commands.

Python (redis-py):

# Good: Single round trip for multiple commands
pipe = redis.pipeline()
for user_id in user_ids:
    pipe.get(f"user:{user_id}")
results = pipe.execute()

Java (Jedis):

import redis.clients.jedis.Pipeline;

// Good: Buffer commands and send as single batch
Pipeline pipe = (Pipeline) jedis.pipelined();

pipe.set("person:1:name", "Alex");
pipe.set("person:1:rank", "Captain");
pipe.set("person:1:serial", "AB1234");

pipe.sync();

Incorrect: Sequential commands in a loop.

Python (redis-py):

# Bad: N round trips
results = []
for user_id in user_ids:
    results.append(redis.get(f"user:{user_id}"))

Java (Jedis):

// Bad: 3 separate round trips
jedis.set("person:1:name", "Alex");
jedis.set("person:1:rank", "Captain");
jedis.set("person:1:serial", "AB1234");

Reference: Redis Pipelining

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 3 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.