query-caching-strategies

aj-geddes/useful-ai-prompts · updated Apr 20, 2026

$npx skills add https://github.com/aj-geddes/useful-ai-prompts --skill query-caching-strategies
0 commentsdiscussion
summary

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

skill.md

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

  // Cache result (TTL: 1 hour)
  await client.setex(cacheKey, 3600, JSON.stringify(user));
  return user;
}

// Cache warming on startup
// ... (see reference guides for full implementation)

Reference Guides

Detailed implementations in the references/ directory:

Guide Contents
Redis Caching with PostgreSQL Redis Caching with PostgreSQL
Memcached Caching Memcached Caching
PostgreSQL Query Cache PostgreSQL Query Cache
MySQL Query Cache MySQL Query Cache
Event-Based Invalidation Event-Based Invalidation
Time-Based Invalidation Time-Based Invalidation, LRU Cache Eviction

Best Practices

✅ DO

  • Follow established patterns and conventions
  • Write clean, maintainable code
  • Add appropriate documentation
  • Test thoroughly before deploying

❌ DON'T

  • Skip testing or validation
  • Ignore error handling
  • Hard-code configuration values

Discussion

Product Hunt–style comments (not star reviews)
  • No comments yet — start the thread.
general reviews

Ratings

4.675 reviews
  • Sophia Diallo· Dec 28, 2024

    Keeps context tight: query-caching-strategies is the kind of skill you can hand to a new teammate without a long onboarding doc.

  • Carlos Choi· Dec 24, 2024

    query-caching-strategies is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.

  • Nia Farah· Dec 20, 2024

    query-caching-strategies is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.

  • Sophia Yang· Dec 20, 2024

    Useful defaults in query-caching-strategies — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.

  • Camila Choi· Dec 16, 2024

    Solid pick for teams standardizing on skills: query-caching-strategies is focused, and the summary matches what you get after install.

  • Carlos Park· Dec 8, 2024

    I recommend query-caching-strategies for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.

  • Yash Thakker· Nov 27, 2024

    I recommend query-caching-strategies for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.

  • Henry Bansal· Nov 19, 2024

    query-caching-strategies has been reliable in day-to-day use. Documentation quality is above average for community skills.

  • Carlos Kim· Nov 15, 2024

    Useful defaults in query-caching-strategies — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.

  • Omar Singh· Nov 15, 2024

    Solid pick for teams standardizing on skills: query-caching-strategies is focused, and the summary matches what you get after install.

showing 1-10 of 75

1 / 8