caching-patterns

caching-patterns is a skill for Claude Code, Codex from vibeeval/vibecosystem. It costs 28 tokens per session (2,216 once invoked), scanned A, original, MIT.

A collection of Redis caching patterns for storing frequently used data temporarily so it can be returned faster than querying a database every time.

In plain words
What is it for?
Use it to design cache keys, set expiration times, load missing values, invalidate old data, and prevent a surge of duplicate database requests.
Why use it?
It helps reduce response time and database load while handling stale data, expiration, and many requests for the same uncached value.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to design cache keys, set expiration times, load missing values, invalidate old data, and prevent a surge of duplicate database requests.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/vibeeval/vibecosystem/caching-patterns
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.

Any agent
npx skills add vibeeval/vibecosystem --skill caching-patterns
Clone the repo
git clone --depth 1 https://github.com/vibeeval/vibecosystem

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for caching-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/vibeeval/vibecosystem/caching-patterns.svg)](https://agentmods.dev/skills/vibeeval/vibecosystem/caching-patterns)
Your own site
<a href="https://agentmods.dev/skills/vibeeval/vibecosystem/caching-patterns"><img src="https://agentmods.dev/badge/skills/vibeeval/vibecosystem/caching-patterns.svg" alt="Measured on agentmods" height="20"></a>
Per session 28 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,216 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
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.1 $0.00028 $0.02216
Opus 5 $0.00014 $0.01108
Sonnet 5 $0.00006 $0.00443
Haiku 4.5 $0.00003 $0.00222

Measured 4d ago against content hash 50c212710035, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

caching-patterns 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 4d 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.

skills/caching-patterns/SKILL.md · 321 lines

How it starts

The opening of the file, as written. The whole thing — 321 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Caching Patterns

Redis-based caching strategies for reducing latency and database load.

Cache Key Design

// Namespace:entity:id format
const CacheKeys = {
  market: (id: string) => `market:v1:${id}`,
  marketList: (filters: string) => `market:list:${filters}`,
  user: (id: string) => `user:v1:${id}`,
  userMarkets: (userId: string, page: number) => `user:${userId}:markets:${page}`,
  leaderboard: () => 'leaderboard:v1:global'
}

// Version prefix allows instant cache bust on schema change:
// bump v1 → v2 to invalidate all market keys without scanning

Cache-Aside (Lazy Loading)

import Redis from 'ioredis'

const redis = new Redis(process.env.REDIS_URL!)
const DEFAULT_TTL = 300  // 5 minutes

async function getOrSet<T>(
  key: string,
  loader: () => Promise<T>,
  ttl = DEFAULT_TTL
): Promise<T> {
  const cached = await redis.get(key)
  if (cached) return JSON.parse(cached) as T

  const value = await loader()
  await redis.setex(key, ttl, JSON.stringify(value))
  return value
}

// Usage
async function getMarket(id: string): Promise<Market> {
  return getOrSet(
    CacheKeys.market(id),
    () => db.market.findUniqueOrThrow({ where: { id } }),
    300
  )
}

Write-Through Pattern

// Write to cache AND database together - cache is always fresh
async function updateMarket(id: string, data: UpdateMarketDto): Promise<Market> {
  const updated = await db.market.update({ where: { id }, data })

  // Synchronously update cache so next read is fresh
  await redis.setex(CacheKeys.market(id), DEFAULT_TTL, JSON.stringify(updated))

  return updated
}

async function deleteMarket(id: string): Promise<void> {
  await db.market.delete({ where: { id } })
  await redis.del(CacheKeys.market(id))
}

Write-Behind (Write-Back) Pattern

// Write to cache immediately, flush to DB asynchronously (higher throughput)
// Risk: data loss on crash if queue not durable

class WriteBehindCache {
  private dirtyKeys = new Set<string>()
  private flushInterval: NodeJS.Timeout

  constructor(private flushEveryMs = 1000) {
    this.flushInterval = setInterval(() => this.flush(), flushEveryMs)
  }

  async write(key: string, value: unknown, dbWriter: () => Promise<void>): Promise<void> {
    // Instant cache update
    await redis.setex(key, DEFAULT_TTL, JSON.stringify(value))
    this.dirtyKeys.add(key)

    // Schedule DB write
    dbWriter().catch(err => {
      console.error(`Write-behind flush failed for ${key}:`, err)
      this.dirtyKeys.add(key)  // re-queue
    })
  }

  private async flush(): Promise<void> {
    // Implementation: drain dirty keys to DB in batch
    this.dirtyKeys.clear()
  }

  destroy(): void {
    clearInterval(this.flushInterval)
  }
}

Read the full file on GitHub · 321 lines

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. 4d ago First seen · 321 lines · 28 tokens per session scan A 50c212710035

Subscribe to this mod's changes

caching-patterns is a skill published in the GitHub repository vibeeval/vibecosystem (530 stars, last pushed 1mo ago), licensed MIT. It adds 28 tokens to every session and 2,216 once invoked, about $0.0001 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-09-03.

Related

Other skills, from other repositories

workstation-offbox-backup

Keep a data-heavy workstation app's local database small and fast while preserving full history off-box, with archived data staying directly readable without a restore step. Splits by data shape — searchable text to a log/search platform, bulk media to snapshotted storage — and pulls data rather than scripting a push.…

dryvist/claude-code-plugins · 100 tokens

db-redis

Inspect Redis instances configured in .env (DBREDISN). Use when the user asks to read keys, check cache state, list keys by pattern, or query info/dbsize on a Redis server. Picks connection by label (e.g. 'cache-dev', 'queue-prod') or numeric index. Read-only in v1 — no SET/DEL/FLUSH exposed.

evolution-foundation/evo-nexus · 81 tokens

redis-state-management

Comprehensive guide for Redis state management including caching strategies, session management, pub/sub patterns, distributed locks, and data structures.

manutej/luxor-claude-marketplace · 28 tokens

pinecone

Managed vector DB for production RAG and search.

NousResearch/hermes-agent · 13 tokens

tanstack-ai-memory-redis

Use when wiring redis() from @tanstack/ai-memory/redis in production — covers client setup (ioredis or node-redis via fromNodeRedis), the storage model, client-side ranking limits, and troubleshooting.

TanStack/ai · 52 tokens

database-expert

Advanced database design and administration for PostgreSQL, MongoDB, and Redis. Use when designing schemas, optimizing queries, managing database performance, or implementing data patterns.

travisjneuman/.claude · 36 tokens