Skip to content
aj-geddes avatar

Query Caching Strategies

Multi-level query caching guide for Redis, Memcached, and database-level caches with invalidation patterns.

CCM score
35 of 100
skills.sh installs
466
GitHub stars
396
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers multi-level caching with Redis, Memcached, and database-level caches, plus cache invalidation, TTL strategies, and cache warming
  • Includes six reference guides: Redis with PostgreSQL, Memcached, PostgreSQL and MySQL query caches, event-based invalidation, and time-based invalidation with LRU eviction
  • Provides a Node.js quick start that checks Redis before querying the database and caches results with a one-hour TTL
  • Designed for setting up caching layers, configuring Redis, and reducing database load on high-read workloads

Install

$ npx -y skills add aj-geddes/useful-ai-prompts --skill query-caching-strategies -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

Query Caching Strategies

Table of Contents

Overview

Implement multi-level caching strategies using Redis, Memcached, and database-level caching. Covers cache invalidation, TTL strategies, and cache warming patterns.

When to Use

  • Query result caching
  • High-read workload optimization
  • Reducing database load
  • Improving response time
  • Cache layer selection
  • Cache invalidation patterns
  • Distributed cache setup

Quick Start

Minimal working example:

// Node.js example with Redis
const redis = require("redis");
const client = redis.createClient({
  host: "localhost",
  port: 6379,
  db: 0,
});

// Get user with caching
async function getUser(userId) {
  const cacheKey = `user:${userId}`;

  // Check cache
  const cached = await client.get(cacheKey);
  if (cached) return JSON.parse(cached);

  // Query database
  const user = await db.query("SELECT * FROM users WHERE id = $1", [userId]);

Details

Repository
github.com/aj-geddes/useful-ai-prompts
Categories
Databases, Backend & APIs
First seen
Jun 3, 2026

Questions

What does the query-caching-strategies skill do?

It implements query caching strategies to improve performance, covering Redis, Memcached and database-level caching. It also covers cache invalidation, TTL strategies and cache warming patterns for speeding up database query response times.

When should I use the query-caching-strategies skill?

Use it when setting up caching layers, configuring Redis, or optimizing database query response times. It also fits high-read workloads, reducing database load and choosing a cache layer.

How do I install the query-caching-strategies skill?

Run npx -y skills add aj-geddes/useful-ai-prompts --skill query-caching-strategies -y in your project. The skill then lets the agent guide query result caching with Redis and related patterns.

Which skills sit alongside query-caching-strategies in the Databases category?

It is listed in the Databases category with supabase-postgres-best-practices, prisma-client-api, prisma-database-setup, prisma-cli and prisma-postgres. Where those cover database access and setup, this skill focuses on caching query results.

More from aj-geddes/useful-ai-prompts

All 258

Similar to Query Caching Strategies

More Databases