agentleFS
seed-forgeseed-forge/harness-ai-kit/skills/public-redis-expert-base/SKILL.md

public-redis-expert-base

Skill25 starsChanged 4 months agoApache-2.0View on GitHub

Redis 知识基座。覆盖数据结构选型、Key 命名、连接池与 Pipeline、集群与副本读取、TTL 与淘汰策略。供 devlab-redis-usage 通过 extends 继承。

The file

We split this skill into the rules it gives an agent

10 rules. About 0 are common, 5 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use colon-separated segments with a stable hierarchy:

    line 40
  2. Distinctive:

    Keep keys short but readable.

    line 51
  3. Distinctive:

    Don't use full URLs or long strings as keys.

    line 52
  4. Distinctive:

    Always use pooling or multiplexing — never one connection per request.

    line 59
  5. Very specific:

    Avoid commands that scan everything: use SCAN instead of KEYS, SSCAN instead of SMEMBERS on large sets.

    line 82
  6. Distinctive:

    Always set TTL for cache keys.

    line 98
  7. Very specific:

    Use EXPIRE / PEXPIRE for time-based eviction.

    line 99
  8. Very specific:

    Never use KEYS * in production — use SCAN.

    line 104
  9. Very specific:

    Never HGETALL or SMEMBERS on large containers — use HSCAN/SSCAN.

    line 105
  10. Distinctive:

    Prefer Hash over serialized String for objects with multiple fields.

    line 106

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Redis Knowledge Base

Foundational guidance for modeling data in Redis and connecting to it efficiently.

Source: Adapted from redis/agent-skills (redis-core + redis-connections + redis-clustering). Official Redis team content.

Workflow

  1. Identify the access pattern (read/write mix, data shape, latency target).
  2. Choose the matching data structure (Section 1).
  3. Design key names following conventions (Section 2).
  4. Configure connection pool and timeouts (Section 3).
  5. Batch work with pipelining (Section 4).
  6. Plan for cluster mode if scaling (Section 5).

Data Structure Selection

Pick the type that matches the access pattern, not just the shape of the data.

Use caseRecommended typeWhy
Simple values, countersStringAtomic INCR/DECR, SET/GET
Object with independently updated fieldsHashPer-field reads/writes, no whole-object rewrite
Queue, recent-N itemsListO(1) push/pop at ends
Unique items, membership checksSetO(1) SADD/SISMEMBER/SCARD
Rankings, score-based rangesSorted SetScore-ordered; ZADD/ZRANGE/ZRANK
Nested / hierarchical dataJSONPath-level updates, nested arrays, RQE indexing
Event log, fan-out messagingStreamPersistent, consumer groups
Vector similarityVector SetNative vector storage with HNSW

Common anti-pattern: stuffing a flat object into a serialized string. Use a Hash instead.

References:

  • choose-data-structure

Key Naming

Use colon-separated segments with a stable hierarchy:

{entity}:{id}:{attribute}
user:1001:profile
session:abc123
article:987:likes

Rules:

  • Lowercase, colon-separated. No spaces, no mixed casing.
  • Keep keys short but readable.
  • Don't use full URLs or long strings as keys.
  • Prefix for multi-tenancy (tenant:42:user:7:cart).

References:

  • key-naming

Connection Management

Always use pooling or multiplexing — never one connection per request.

StyleUsed byNote
Poolredis-py, Jedis, go-redisEach lease blocks if pool exhausted
MultiplexLettuce, NRedisStackSingle connection; cannot carry blocking commands

Set explicit timeouts: connect timeout shorter than read/write timeout.

References:

  • pooling
  • timeouts

Pipelining & Batching

For N commands that don't depend on each other's results, send as a single batch.

pipe = redis.pipeline()
for user_id in user_ids:
    pipe.get(f"user:{user_id}")
results = pipe.execute()

Avoid commands that scan everything: use SCAN instead of KEYS, SSCAN instead of SMEMBERS on large sets.

References:

  • pipelining
  • blocking-commands

Clustering & Replication

In Redis Cluster, keys are distributed across 16,384 slots. Multi-key operations require all keys on the same slot — use hash tags: {user:1001}:profile.

For read-heavy workloads, route reads to replicas (eventually consistent).

References:

  • hash-tags
  • read-replicas

TTL & Eviction

  • Always set TTL for cache keys; never rely on manual cleanup.
  • Use EXPIRE / PEXPIRE for time-based eviction.
  • Choose eviction policy based on workload: allkeys-lru for cache, volatile-lru for mixed.
  • Monitor evicted_keys in INFO stats to detect memory pressure.

Guardrails

  • Never use KEYS * in production — use SCAN.
  • Never HGETALL or SMEMBERS on large containers — use HSCAN/SSCAN.
  • Prefer Hash over serialized String for objects with multiple fields.
  • Set TTL on all cache keys; avoid manual cleanup patterns.

参考文档:

  • references/REFERENCE-README.md

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.