Implement efficient caching strategies using Redis, Memcached, CDN, and cache invalidation patterns. Use when optimizing application performance, reducing database load, or improving response times.
3f5182cImplement effective caching strategies to improve application performance, reduce latency, and decrease load on backend systems.
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)
Detailed implementations in the references/ directory:
| Guide | Contents | |---|---| | Redis Cache Implementation (Node.js) | Redis Cache Implementation (Node.js) | | Cache Decorator (Python) | Cache Decorator (Python) | | Multi-Level Cache | Multi-Level Cache | | Cache Invalidation Strategies | Cache Invalidation Strategies | | HTTP Caching Headers | HTTP Caching Headers |
Copy a source-pinned command for your client. You run it yourself.
Destination: .claude/skills/caching-strategy · pinned to the source commit
git clone https://github.com/aj-geddes/useful-ai-prompts.git
cd useful-ai-prompts
git checkout 3f5182cfd739fc113f4af5244a1cf342ad7f7911
mkdir -p ".claude/skills/caching-strategy"
cp -r "skills/caching-strategy" ".claude/skills/caching-strategy"Review the source before running. This copies files into your project; it is not a one-click install and does not verify runtime safety.
Scanner static-checks@0.1.0 · commit 3f5182cfd739. Static checks cannot prove runtime safety – review the source and the exact diff before installing. How checks work.
No static rules matched. This is not a safety guarantee.