Agent skill

Implementing Database Caching

by jeremylongshore in jeremylongshore/tons-of-skills-marketplace

Process use when you need to implement multi-tier caching to improve database performance.

MITAuto-check passedBackend & APIs

Install Implementing Database Caching

skills CLI
$ npx skills add jeremylongshore/tons-of-skills-marketplace --skill implementing-database-caching -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install jeremylongshore/tons-of-skills-marketplace implementing-database-caching --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/jeremylongshore/tons-of-skills-marketplace.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/.curated/implementing-database-caching .claude/skills/implementing-database-caching && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
implementing-database-caching
GitHub stars
2.8k
Token cost
~1.8k tokens
SKILL.md length
860 words
Files
5 (incl. scripts, references, assets)
Skills in repo
3,342
Repo updated
First seen
Licence
MIT

At a glance

Process use when you need to implement multi-tier caching to improve database performance.

  • Works in 10 steps: Profile database queries to identify… → Design the cache key schema with a… → Implement the cache-aside pattern for… → …
  • You need to implement multi-tier caching to improve database performance
  • SKILL.md covers Overview, Prerequisites, Instructions and Output, plus 3 more sections
  • Runs Python scripts from its folder; calls docker and redis-cli

What it does

Implementing Database Caching is an agent skill from jeremylongshore/tons-of-skills-marketplace. Process use when you need to implement multi-tier caching to improve database performance. This skill sets up Redis, in-memory caching, and CDN layers to reduce database load. Trigger with phrases like "implement database caching", "add Redis cache layer", "improve query performance with caching", or "reduce database load".

Its SKILL.md is about 1.8k tokens, which your agent loads only when the skill is triggered. The skill folder holds 7 other files, including scripts, reference files and assets (for example `assets/README.md`, `references/README.md` and `scripts/README.md`). Compatibility notes: Designed for Claude Code

It sits in Backend & APIs, covering Caching and Query optimization. It works with Redis. The repository describes itself as: Model-agnostic agent-skills platform with a harness-free canonical layer, verified adapters, and the ccpi package manager. Explore at tonsofskills.com. The licence is MIT.

When your agent uses it

  • You need to implement multi-tier caching to improve database performance
  • With phrases like implement database caching
  • Add Redis cache layer
  • Improve query performance with caching

Example prompts

  • “implement database caching”
  • “add Redis cache layer”
  • “improve query performance with caching”
  • “/implementing-database-caching”

Requirements

  • Python 3
  • Node.js
  • Docker
  • Compatibility (from SKILL.md): Designed for Claude Code
  • Pre-approved tools (allowed-tools): Read, Write, Edit, Grep, Glob, Bash(redis-cli:*), Bash(docker:redis:*)

Workflow steps

10 steps, taken from the first numbered list in SKILL.md.

  1. Profile database queries to identify caching candidates. Focus on queries that: execute more than 100 times per minute, take longer than…
  2. Design the cache key schema with a consistent naming convention: service:entity:identifier:variant. Examples: app:user:12345:profile…
  3. Implement the cache-aside pattern for read-heavy data
  4. Configure TTL values based on data change frequency
  5. Implement cache stampede prevention for high-traffic cache keys
  6. Add application-level L1 cache using an in-memory LRU cache (Node.js: lru-cache, Python: cachetools, Java: Caffeine) for per-process…
  7. Configure Redis for production
  8. Implement cache invalidation on data mutations. After INSERT, UPDATE, or DELETE operations, delete the corresponding cache key and any…
  9. Add cache metrics instrumentation: track cache hit rate (hits / (hits + misses)), cache miss latency (time to populate from DB), Redis…
  10. Test cache behavior under load: verify cache hit rate reaches 90%+ for targeted queries, confirm cache invalidation works correctly on…

What it can do on your machine

Read from SKILL.md and the folder at commit 23ea8d4. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Read
    • Write
    • Edit
    • Grep
    • Glob
    • Bash(redis-cli:*)
    • Bash(docker:redis:*)

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 2 files in scripts/ (Python), which the agent can run.

    Shell commands in SKILL.md call:

    • docker
    • redis-cli

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • redis.io
    • docs.microsoft.com
    • github.com
    • redis-py.readthedocs.io

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

  • Compatibility

    Designed for Claude Code

    From compatibility in the SKILL.md frontmatter.

Context cost

Implementing Database Caching loads about 1.8k tokens when it runs, and up to ~1.9k if it reads all its reference files. Until then it costs about 89 tokens; SKILL.md has 860 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~89
When it runs · the whole SKILL.md, loaded when a task matches
~1.8k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~1.9k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from jeremylongshore/tons-of-skills-marketplace at commit 23ea8d4, republished under its MIT licence (© jeremylongshore). 860 words, ~1,847 tokens.

Download SKILL.mdSave it as .claude/skills/implementing-database-caching/SKILL.md (or your agent's skills folder). This skill also uses 4 other files; get the full folder from GitHub.
name
implementing-database-caching
description
Process use when you need to implement multi-tier caching to improve database performance. This skill sets up Redis, in-memory caching, and CDN layers to reduce database load. Trigger with phrases like "implement database caching", "add Redis cache layer", "improve query performance with caching", or "reduce database load".
allowed-tools
Read, Write, Edit, Grep, Glob, Bash(redis-cli:*), Bash(docker:redis:*)
compatibility
Designed for Claude Code
version
1.29.0
author
Jeremy Longshore <jeremy@intentsolutions.io>
license
MIT
tags
database, redis, performance

Database Cache Layer

Overview

Implement multi-tier caching strategies using Redis, application-level in-memory caches, and query result caching to reduce database load and improve read latency. This skill covers cache-aside, write-through, and write-behind patterns with proper invalidation strategies, TTL configuration, and cache stampede prevention.

Prerequisites

  • Redis server (6.x+) available or Docker for running docker run redis:7-alpine
  • redis-cli installed for cache inspection and debugging
  • Application framework with Redis client library (ioredis, redis-py, Jedis, go-redis)
  • Database query profiling data identifying read-heavy and slow queries
  • Understanding of data freshness requirements (how stale can cached data be)
  • Monitoring tools for cache hit rate and Redis memory usage

Instructions

  1. Profile database queries to identify caching candidates. Focus on queries that: execute more than 100 times per minute, take longer than 50ms, return data that changes less frequently than every 5 minutes, and produce results smaller than 1MB. Use pg_stat_statements or MySQL slow query log.

  2. Design the cache key schema with a consistent naming convention: service:entity:identifier:variant. Examples: app:user:12345:profile, app:products:category:electronics:page:1. Include a version prefix to enable bulk invalidation: v2:app:user:12345.

  3. Implement the cache-aside pattern for read-heavy data:

    • Check Redis first: GET app:user:12345:profile
    • On cache miss: query database, then SET app:user:12345:profile <json> EX 3600
    • On data update: DEL app:user:12345:profile to invalidate
    • Wrap in a helper function that abstracts cache-then-database logic
  4. Configure TTL values based on data change frequency:

    • Static reference data (countries, categories): TTL 24 hours or longer
    • User profile data: TTL 15-60 minutes
    • Product listings: TTL 5-15 minutes
    • Session data: TTL matching session timeout
    • Real-time data (inventory counts, prices): TTL 30-60 seconds or skip caching
  5. Implement cache stampede prevention for high-traffic cache keys:

    • Probabilistic early expiration: Refresh cache at TTL * 0.8 with probability 1 / concurrent_requests
    • Distributed lock: Use SET key:lock NX EX 5 to let one request refresh while others serve stale data
    • Stale-while-revalidate: Serve expired cache while refreshing in background
  6. Add application-level L1 cache using an in-memory LRU cache (Node.js: lru-cache, Python: cachetools, Java: Caffeine) for per-process caching of ultra-hot data. Set L1 TTL shorter than Redis TTL (e.g., 60 seconds L1, 5 minutes Redis).

  7. Configure Redis for production:

    • Set maxmemory to 75% of available RAM
    • Set maxmemory-policy allkeys-lru for cache workloads
    • Enable save "" (disable RDB persistence) for pure cache use
    • Configure tcp-keepalive 60 and timeout 300
  8. Implement cache invalidation on data mutations. After INSERT, UPDATE, or DELETE operations, delete the corresponding cache key and any aggregate/list cache keys that include the modified data. Use Redis key patterns or tag-based invalidation for related keys.

  9. Add cache metrics instrumentation: track cache hit rate (hits / (hits + misses)), cache miss latency (time to populate from DB), Redis memory usage, eviction rate, and average key TTL remaining. Alert when hit rate drops below 80%.

  10. Test cache behavior under load: verify cache hit rate reaches 90%+ for targeted queries, confirm cache invalidation works correctly on updates, and measure end-to-end latency improvement compared to direct database queries.

Output

  • Redis configuration file with memory limits, eviction policy, and persistence settings
  • Cache wrapper module with get/set/invalidate functions and stampede prevention
  • Cache key schema documentation with naming conventions and TTL values per data type
  • Invalidation logic integrated with data access layer for automatic cache clearing on mutations
  • Monitoring dashboard queries for cache hit rate, memory usage, and eviction tracking
Show full SKILL.md (318 more words)Show less

Error Handling

ErrorCauseSolution
Redis connection refusedRedis server down or network issueImplement circuit breaker pattern; fall through to database on cache unavailability; retry with exponential backoff
Cache stampede on popular key expirationMany concurrent requests hit cache miss simultaneouslyUse distributed locking or probabilistic early refresh; extend TTL with jitter (TTL + random(0, TTL*0.1))
Stale data served after database updateCache invalidation missed or delayedAudit invalidation paths; use publish/subscribe for cache invalidation events; reduce TTL for sensitive data
Redis out of memory (OOM)Cache size exceeds maxmemory settingEnable allkeys-lru eviction; reduce TTLs; audit large keys with redis-cli --bigkeys; increase maxmemory
Cache key collisionDifferent data stored under the same key patternInclude all discriminating parameters in the cache key; add content hash to key for variant detection

Examples

Caching product catalog for an e-commerce site: Product detail pages query 3 tables (products, categories, reviews_summary). Cache the assembled product JSON in Redis with TTL of 10 minutes. Cache hit rate reaches 95% since products change rarely. Category pages use list cache keys app:products:category:electronics:sort:price:page:1 with 5-minute TTL. On product update, invalidate both the product key and all category list keys containing that product.

User session caching with Redis: Store session data as Redis hashes (HSET session:abc123 userId 456 role admin lastAccess 1705341234). Set TTL to 30 minutes with sliding expiration on each access (EXPIRE session:abc123 1800). Session reads drop from 2ms (PostgreSQL) to 0.1ms (Redis), eliminating 50,000 database queries per minute.

API response caching with stale-while-revalidate: Dashboard endpoint takes 3 seconds to compute. Cache the response with 5-minute TTL. When TTL expires, the first request triggers an async background refresh while serving the stale cached response. Subsequent requests within the refresh window also receive the stale response. Dashboard always loads in under 5ms from the client perspective.

Resources

© jeremylongshore, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 4 other files (scripts, references, assets) in skills/.curated/implementing-database-caching of jeremylongshore/tons-of-skills-marketplace.

  • SKILL.md
  • assets/README.md
  • references/README.md
  • scripts/README.md
  • scripts/redis_setup.py

Open the folder on GitHubat commit 23ea8d4

Compare with similar skills

Implementing Database Caching next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Implementing Database Caching compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Implementing Database Caching this skilljeremylongshore/tons-of-skills-marketplace2.8k—~1.8kAutomated safety check: PassMIT
Database Domain Specialistmodu-ai/moai-adk1.2k—~2.8kAutomated safety check: PassApache-2.0
Wp Performancegambitph/Stackable3503 repos~1.5kAutomated safety check: PassGPL-3.0
FastAPI-Redis SDK Developmentredis/fastapi-redis-sdk404—~2.5kAutomated safety check: NotesMIT
Redis Patternsaffaan-m/ECC275k1 repos~3kAutomated safety check: PassMIT
Amazon Elasticacheaws/agent-toolkit-for-aws2.8k—~4.5kAutomated safety check: PassApache-2.0

Similar skills

  • Database guidance for PostgreSQL, MongoDB, Redis and Oracle plus Neon, Supabase and Firestore: schema design, indexing, query tuning and cloud database choice.

    1.2k GitHub stars~2.8k tokensUpdated today
    DatabasesAuto-check passed
  • Wp Performance

    gambitph/Stackable

    A skill your agent uses when investigating or improving WordPress performance (backend-only agent): profiling and measurement (WP-CLI profile/doctor, Server-Timing, Query Monitor via REST headers)…

    350 GitHub starsUsed in 3 repos~1.5k tokens
    Backend & APIsAuto-check passed
  • FastAPI-Redis SDK Development

    redis/fastapi-redis-sdk

    Official

    Guides development on the fastapi-redis-sdk library itself - its connection lifecycle, dependency-injected caching, and async/sync bridging.

    404 GitHub stars~2.5k tokensUpdated 6 days ago
    Backend & APIsAuto-check: notes
  • Redis Patterns

    affaan-m/ECC

    Redis data structure patterns, caching strategies, distributed locks, rate limiting, pub/sub, and connection management for production applications.

    275k GitHub starsUsed in 1 repo~3k tokens
    Backend & APIsAuto-check passed
  • Amazon Elasticache

    aws/agent-toolkit-for-aws

    Official

    Activate when developers have latent caching needs: slow API responses, database read bottlenecks, DynamoDB throttling or cost, RDS/Aurora scaling pressure, Bedrock latency or cost, or adding a…

    2.8k GitHub stars~4.5k tokensUpdated today
    Backend & APIsAuto-check passed
  • Upstash Redis

    sickn33/agentic-awesome-skills

    Use the @upstash/redis HTTP client for caching, sessions, counters, and Redis data structures from serverless and edge runtimes without connection pooling.

    47k GitHub starsUsed in 1 repo~1.5k tokens
    Backend & APIsAuto-check passed

More from jeremylongshore/tons-of-skills-marketplace

All 3,342 skills in this repo
  • Performing Security Code Review

    jeremylongshore/tons-of-skills-marketplace

    Execute this skill enables AI assistant to conduct a security-focused code review using the security-agent plugin.

    2.8k GitHub starsUsed in 2 repos~1.3k tokens
    Auto-check: notes
  • Analyzing Text With NLP

    jeremylongshore/tons-of-skills-marketplace

    Execute this skill enables AI assistant to perform natural language processing and text analysis using the nlp-text-analyzer plugin.

    2.8k GitHub starsUsed in 1 repo~819 tokens
    Auto-check passed
  • Building Neural Networks

    jeremylongshore/tons-of-skills-marketplace

    Execute this skill allows AI assistant to construct and configure neural network architectures using the neural-network-builder plugin.

    2.8k GitHub starsUsed in 1 repo~1k tokens
    Auto-check passed
  • Detecting Data Anomalies

    jeremylongshore/tons-of-skills-marketplace

    Process identify anomalies and outliers in datasets using machine learning algorithms.

    2.8k GitHub starsUsed in 1 repo~1.4k tokens
    Auto-check passed
  • Explaining Machine Learning Models

    jeremylongshore/tons-of-skills-marketplace

    Build this skill enables AI assistant to provide interpretability and explainability for machine learning models.

    2.8k GitHub starsUsed in 1 repo~1k tokens
    Auto-check passed
  • Optimizing Prompts

    jeremylongshore/tons-of-skills-marketplace

    Execute this skill optimizes prompts for large language models (llms) to reduce token usage, lower costs, and improve performance.

    2.8k GitHub starsUsed in 1 repo~1k tokens
    Auto-check passed

Works with

Questions about Implementing Database Caching

What does Implementing Database Caching do?

Process use when you need to implement multi-tier caching to improve database performance. Implementing Database Caching is an agent skill from jeremylongshore/tons-of-skills-marketplace. Process use when you need to implement multi-tier caching to improve database performance.

When should I use Implementing Database Caching?

Implementing Database Caching fits situations like: you need to implement multi-tier caching to improve database performance; with phrases like implement database caching; add Redis cache layer; improve query performance with caching.

How do I install Implementing Database Caching in Claude Code?

Run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill implementing-database-caching -a claude-code`. Or copy the skill folder (skills/.curated/implementing-database-caching in jeremylongshore/tons-of-skills-marketplace) into .claude/skills/implementing-database-caching in your project. Claude Code loads it when a task matches its description.

How do I install Implementing Database Caching in Codex?

Run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill implementing-database-caching -a codex`. Or copy the skill folder (skills/.curated/implementing-database-caching in jeremylongshore/tons-of-skills-marketplace) into .agents/skills/implementing-database-caching in your project. Codex loads it when a task matches its description.

Can I use Implementing Database Caching in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill implementing-database-caching -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/implementing-database-caching, .gemini/skills/implementing-database-caching, .github/skills/implementing-database-caching and .opencode/skills/implementing-database-caching in your project.

What does Implementing Database Caching need to run?

Going by SKILL.md and its folder, Implementing Database Caching needs Python for the scripts in its folder and the command-line tools its instructions call (docker and redis-cli). Our summary lists: Python 3; Node.js; Docker. Its frontmatter pre-approves these tools: Read, Write, Edit, Grep, Glob, Bash(redis-cli:*), Bash(docker:redis:*). Compatibility (from SKILL.md): Designed for Claude Code.

Does Implementing Database Caching access the network?

SKILL.md names 4 domains. As links in the text: redis.io, docs.microsoft.com, github.com and redis-py.readthedocs.io. This is read from the text; nothing was executed.

Is Implementing Database Caching safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Implementing Database Caching use?

Implementing Database Caching is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Implementing Database Caching use?

About 1.8k tokens (SKILL.md is roughly 7.4k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 16 tokens, read only when the agent opens those files.

What are the alternatives to Implementing Database Caching?

Skills that share tags, products or a category with Implementing Database Caching: Database Domain Specialist (modu-ai/moai-adk, 1.2k stars), Wp Performance (gambitph/Stackable, 350 stars), FastAPI-Redis SDK Development (redis/fastapi-redis-sdk, 404 stars) and Redis Patterns (affaan-m/ECC, 275k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Implementing Database Caching?

jeremylongshore (a GitHub user) maintains it in jeremylongshore/tons-of-skills-marketplace, which has 2,821 GitHub stars. The repository holds 3,342 skills in this directory. The repository was last updated on October 8, 2026.

Source: jeremylongshore/tons-of-skills-marketplace on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.