aj-geddes avatar

Query Caching Strategies

This walks you through multi-level caching with Redis, Memcached, and database-level strategies. You get patterns for cache invalidation (both event-based and time-based), TTL configuration, and cache warming on startup. The quick start shows a basic Redis implementation with PostgreSQL, and the reference guides cover specific database pairings plus LRU eviction strategies. Honestly, the value here is having the invalidation patterns laid out clearly, since that's usually where caching implementations get messy. Good fit if you're adding a cache layer to an existing system or trying to reduce database load on high-read workloads.

skills.sh installs
465
GitHub stars
379
last updated
Aug 21, 2026

Install

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

Installs into .claude/skills of the current project.

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]);

Sponsors

Details

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

More from aj-geddes/useful-ai-prompts

All 258
1jezweb avatarcloudflare-r2jezweb/claude-skillsStore objects with R2's S3-compatible storage on Cloudflare's edge. Use when: uploading/downloading files, configuring CORS, generating presigned URLs, multipar462skills.sh installs
2ejirocodes avatarnestjs-best-practicesejirocodes/agent-skillsNestJS 11+ best practices for enterprise Node.js applications with TypeScript. Use when writing, reviewing, or refactoring NestJS controllers, services, modules460skills.sh installs
3martinholovsky avatarcelery-expertmartinholovsky/claude-skills-generatorExpert Celery distributed task queue engineer specializing in async task processing, workflow orchestration, broker configuration (Redis/RabbitMQ), Celery Beat 458skills.sh installs
4postman-devrel avatarpostmanpostman-devrel/agent-skillsFull API lifecycle management through Postman. Sync OpenAPI specs to collections, generate typed client code, run API tests, create mock servers, publish docume458skills.sh installs
5aj-geddes avatarstored-proceduresaj-geddes/useful-ai-promptsImplement stored procedures and functions for database logic. Use when creating reusable database routines, complex queries, or server-side calculations.457skills.sh installs
6manutej avatarpytestmanutej/luxor-claude-marketplaceAdvanced Python unit testing framework for customer support tech enablement, covering FastAPI, SQLAlchemy, PostgreSQL, async operations, mocking, fixtures, para457skills.sh installs