redis

A set of coding rules for Redis, an in-memory data store used for caching, queues, counters, and other data structures. It covers key naming, expiration, caching, performance, and safe command usage.

In plain words
What is it for?
It is for designing Redis keys, caches, queues, leaderboards, rate limiters, event streams, expiration policies, pipelines, and Lua scripts.
Why use it?
It helps developers choose suitable Redis data types and avoid problems such as blocking commands, stale cache entries, excessive network trips, and cache stampedes.

Cursor rule

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/nedcodes-ok/cursor-doctor/redis
Clone the repo
git clone --depth 1 https://github.com/nedcodes-ok/cursor-doctor
Per session 468 This file is loaded in full into every session.
When invoked 468 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00468 $0.00468
Opus 5 $0.00234 $0.00234
Sonnet 5 $0.00094 $0.00094
Haiku 4.5 $0.00047 $0.00047

Measured 2d ago against content hash 63862b1627e6, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

redis scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

Copies of this mod

1 near-identical copy found in the catalogue:

pro-kit/templates/tools/redis.mdc · 50 lines

What it actually says

Redis Cursor Rules

You are an expert Redis developer. Follow these rules:

Data Structures

  • Strings for simple key-value and counters (INCR/DECR are atomic)
  • Hashes for objects — HSET user:123 name "Alice" email "alice@..."
  • Sorted sets for leaderboards, rate limiters, priority queues
  • Lists for queues (LPUSH/RPOP) and activity feeds
  • Sets for unique collections and intersection/union operations
  • Streams for event sourcing and message queues

Key Design

  • Namespace keys with colons: user:123:session, post:456:likes
  • Keep keys short but readable — abbreviate namespaces in high-volume scenarios
  • Set TTL on every cache key — no key should live forever without reason
  • Use SCAN over KEYS — KEYS blocks the single-threaded server

Caching Patterns

  • Cache-aside: app checks cache, falls back to DB, writes to cache
  • Write-through for data that must stay consistent
  • TTL-based invalidation for most use cases. Event-based for critical consistency
  • Serialize as JSON or MessagePack — avoid language-specific formats
  • Cache stampede prevention: use locks or stale-while-revalidate

Performance

  • Pipeline multiple commands to reduce round trips
  • Lua scripts for atomic multi-step operations (EVAL/EVALSHA)
  • Avoid large values (>100KB) — split into smaller keys
  • Use OBJECT ENCODING to verify memory-efficient encodings
  • Monitor with INFO stats, SLOWLOG, and CLIENT LIST

Pub/Sub & Streams

  • Pub/Sub for fire-and-forget broadcasting — messages are lost if no subscriber
  • Streams for persistent messaging with consumer groups
  • XACK processed messages. Set MAXLEN to cap stream size
  • Use consumer groups for distributed work distribution

Operations

  • Redis Sentinel for high availability, Redis Cluster for horizontal scaling
  • RDB snapshots for backups. AOF for durability
  • maxmemory-policy: allkeys-lru for caches, noeviction for primary data
  • Monitor memory with INFO memory — watch fragmentation ratio
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 50 lines · 468 tokens per session scan A 63862b1627e6

Subscribe to this mod's changes

redis is a cursor rule published in the GitHub repository nedcodes-ok/cursor-doctor (9 stars, last pushed 5mo ago), licensed MIT. It adds 468 tokens to every session, about $0.0023 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.