mcpField
C
caching-strategy

caching-strategy

github.com/aj-geddesDevelopment373547 installsUpdated 34w ago
Repository

About caching-strategy

A caching-strategy skill for developers seeking to improve application performance and reduce backend load. It provides guidance on cache patterns, invalidation, and implementations across several approaches.

Key features

  1. 01Redis caching in Node.js
  2. 02Python cache decorator
  3. 03Multi-level caching
  4. 04Cache invalidation strategies
  5. 05HTTP caching headers

Use cases

  1. 01Reducing database query load
  2. 02Improving API response times
  3. 03Caching expensive computations
  4. 04Applying distributed caching

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/aj-geddes/useful-ai-prompts --skill caching-strategy

After installing, type/caching-strategyin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

references/
cache-decorator-python.md
cache-invalidation-strategies.md
http-caching-headers.md
multi-level-cache.md
redis-cache-implementation-nodejs.md
scripts/
validate-api.sh
templates/
api-scaffold.yaml

Details

From the project README

Caching Strategy

Table of Contents

Overview

Implement effective caching strategies to improve application performance, reduce latency, and decrease load on backend systems.

When to Use

  • Reducing database query load
  • Improving API response times
  • Handling high traffic loads
  • Caching expensive computations
  • Storing session data
  • CDN integration for static assets
  • Implementing distributed caching
  • Rate limiting and throttling

Quick Start

Minimal working example:

import Redis from "ioredis";

interface CacheOptions {
  ttl?: number; // Time to live in seconds
  prefix?: string;
}

class CacheService {
  private redis: Redis;
  private defaultTTL = 3600; // 1 hour

  constructor(redisUrl: string) {
    this.redis = new Redis(redisUrl, {
      retryStrategy: (times) => {
        const delay = Math.min(times * 50, 2000);
        return delay;
      },
      maxRetriesPerRequest: 3,
    });

    this.redis.on("connect", () => {
      console.log("Redis connected");
    });

    this.redis.on("error", (error) => {
// ... (see reference guides for full implementation)

Reference Guides

Detailed implementations in the references/ directory:

GuideContents
Redis Cache Implementation (Node.js)Redis Cache Implementation (Node.js)
Cache Decorator (Python)Cache Decorator (Python)
Multi-Level CacheMulti-Level Cache
Cache Invalidation StrategiesCache Invalidation Strategies
HTTP Caching HeadersHTTP Caching Headers

Best Practices

✅ DO
  • Set appropriate TTL values
  • Implement cache warming for critical data
  • Use cache-aside pattern for reads
  • Monitor cache hit rates
  • Implement graceful degradation on cache failure
  • Use compression for large cached values
  • Namespace cache keys properly
  • Implement cache stampede prevention
  • Use consistent hashing for distributed caching
  • Monitor cache memory usage
❌ DON'T
  • Cache everything indiscriminately
  • Use caching as a fix for poor database design
  • Store sensitive data without encryption
  • Forget to handle cache misses
  • Set TTL too long for frequently changing data
  • Ignore cache invalidation strategies
  • Cache without monitoring
  • Store large objects without consideration

Comments

Markdown supported