본문으로 건너뛰기
cccskills
무료GitHub에 공개

cache-strategy-invalidation-expert

Redis caching patterns, cache-aside, write-through, TTL strategies, and invalidation. Activate on: caching, Redis, cache invalidation, cache-aside, write-through, TTL, CDN cache, stale-while-revalidate. NOT for: CDN/reverse proxy setup (use api-gateway-reverse-proxy-expert), database query optimization (use data-warehouse-optimizer).

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

연동 도구Redis
설치 방법 보기

포함된 파일(1)

  • SKILL.md5.5 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Cache Strategy & Invalidation Expert

Design and implement caching architectures using Redis, application-level caching, and CDN layers with reliable invalidation strategies.

Activation Triggers

Activate on: "caching", "Redis cache", "cache invalidation", "cache-aside", "write-through", "TTL", "stale-while-revalidate", "cache stampede", "cache warming"

NOT for: CDN/proxy configuration → api-gateway-reverse-proxy-expert | Database query tuning → data-warehouse-optimizer | Connection pooling → database-connection-pool-manager

Quick Start

  1. Identify cache candidates — read-heavy, expensive to compute, tolerant of staleness
  2. Choose pattern — cache-aside (most common), write-through (consistency), write-behind (performance)
  3. Set TTL strategy — short TTL for volatile data (60s), long TTL + event invalidation for stable data
  4. Prevent stampede — use probabilistic early refresh or mutex lock on cache miss
  5. Monitor hit rate — target >90% hit rate; below 70% means your cache strategy is wrong

Core Capabilities

DomainTechnologies
In-MemoryRedis 7.4+, Valkey, DragonflyDB, KeyDB
ApplicationNode LRU cache, Cacheable, unstorage
HTTP/CDNCache-Control, stale-while-revalidate, Surrogate-Key
Multi-LayerL1 (in-process) → L2 (Redis) → L3 (CDN)
InvalidationEvent-driven purge, TTL, tag-based (Surrogate-Key)

Architecture Patterns

Cache-Aside with Stampede Prevention

import { Redis } from 'ioredis';

const redis = new Redis();
const LOCK_TTL = 5; // seconds

async function cacheAside<T>(
  key: string,
  ttl: number,
  fetcher: () => Promise<T>
): Promise<T> {
  // Try cache first
  const cached = await redis.get(key);
  if (cached) return JSON.parse(cached);

  // Acquire lock to prevent stampede
  const lockKey = `lock:${key}`;
  const acquired = await redis.set(lockKey, '1', 'EX', LOCK_TTL, 'NX');

  if (!acquired) {
    // Another process is fetching — wait and retry
    await new Promise(r => setTimeout(r, 100));
    return cacheAside(key, ttl, fetcher);
  }

  try {
    const data = await fetcher();
    await redis.set(key, JSON.stringify(data), 'EX', ttl);
    return data;
  } finally {
    await redis.del(lockKey);
  }
}

Multi-Layer Cache Architecture

Request → L1: In-Process (LRU, 100ms TTL, ~1000 items)
              │ miss
              ↓
          L2: Redis (5-60min TTL, shared across instances)
              │ miss
              ↓
          L3: CDN (Cache-Control headers, edge-cached)
              │ miss
              ↓
          Origin (database/API)

Invalidation flows BACKWARD:
  Database change → Purge L2 (Redis DEL) → L1 expires via short TTL
                 → Purge L3 (Surrogate-Key purge / CDN API)

Event-Driven Invalidation

// On data change, publish invalidation event
async function updateUser(userId: string, data: UserUpdate) {
  await db.users.update(userId, data);

  // Invalidate all cache layers
  await redis.del(`user:${userId}`);
  await redis.del(`user:${userId}:profile`);

  // Publish for other instances' L1 caches
  await redis.publish('cache:invalidate', JSON.stringify({
    pattern: `user:${userId}:*`,
    timestamp: Date.now(),
  }));

  // CDN purge by surrogate key
  await cdn.purgeTag(`user-${userId}`);
}

Anti-Patterns

  1. Cache everything — caching write-heavy, rarely-read data wastes memory and creates invalidation headaches
  2. No TTL — every cache entry must expire; relying solely on explicit invalidation will eventually leave stale data
  3. Cache-then-forget — monitor hit rate, eviction rate, and memory usage; an unmonitored cache silently degrades
  4. Serializing full objects — cache only what you need; storing entire ORM models bloats memory and couples cache to schema
  5. Invalidation by pattern scan — KEYS user:* blocks Redis; use sets to track related keys or hash structures

Quality Checklist

  • Cache-aside pattern with stampede prevention (mutex or probabilistic refresh)
  • TTL set on every key (no eternal cache entries)
  • Hit rate monitored and >90% for primary caches
  • Invalidation strategy defined: TTL-based, event-driven, or hybrid
  • Cache keys include all relevant context (tenant, locale, version)
  • Redis memory policy set (allkeys-lru for cache workloads)
  • No KEYS * or SCAN in hot paths (use sets for key tracking)
  • Multi-layer cache with clear TTL hierarchy (L1 < L2 < L3)
  • Graceful degradation: app works (slower) if cache is down
  • Cache warming strategy for cold starts after deployments

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Expert in 2000s-era music visualization (Milkdrop, AVS, Geiss) and modern WebGL implementations. Specializes in Butterchurn integration, Web Audio API AnalyserNode FFT data, GLSL shaders for audio-reactive visuals, and psychedelic generative art. Activate on "Milkdrop", "music visualization", "WebGL visualizer", "Butterchurn", "audio reactive", "FFT visualization", "spectrum analyzer". NOT for simple bar charts/waveforms (use basic canvas), video editing, or non-audio visuals.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

curiositech/port-daddy32026년 10월 18일 업데이트

Expert legal research agent for finding and scraping expungement data state by state. Knows authoritative sources, URL patterns, Firecrawl configuration, and 2026 legal landscape.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

curiositech/port-daddy32026년 10월 18일 업데이트

Expert in 3D computer vision labeling tools, workflows, and AI-assisted annotation for LiDAR, point clouds, and sensor fusion. Covers SAM4D/Point-SAM, human-in-the-loop architectures, and vertical-specific training strategies. Activate on '3D labeling', 'point cloud annotation', 'LiDAR labeling', 'SAM 3D', 'SAM4D', 'sensor fusion annotation', '3D bounding box', 'semantic segmentation point cloud'. NOT for 2D image labeling (use clip-aware-embeddings), general ML training (use ml-engineer), video annotation without 3D (use computer-vision-pipeline), or VLM prompt engineering (use prompt-engineer).

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

curiositech/port-daddy32026년 10월 18일 업데이트

Apply crisis decision-making research to agent routing, uncertainty triage, and coordination failure analysis in time-pressured systems. Use when diagnosing handoff failures, analytical paralysis, or expert judgment under incomplete information. NOT for routine coding, simple CRUD design, or static single-agent tasks with complete information.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

curiositech/port-daddy32026년 10월 18일 업데이트

Use for insight, reframing, contradiction, impasse, and anomaly-driven problem solving when execution effort no longer helps. NOT for routine optimization, error correction, or well-specified tasks with known solution paths.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

curiositech/port-daddy32026년 10월 18일 업데이트

Apply cognitive task analysis to expert work that depends on perceptual cues, branching judgment, and recurring monitoring loops. Use when decomposing expert capability into agent structure, simulation design, or validation interviews. NOT for ordinary step-by-step SOP capture or simple pipelines with no tacit cue layer.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

curiositech/port-daddy32026년 10월 18일 업데이트

curiositech의 스킬 모두 보기

이 스킬의 문제 신고