スキル一覧に戻る
j0KZ

caching-optimizer

by j0KZ

8 powerful AI development tools for Claude Code, Cursor, Windsurf - Code review, testing, architecture, security, and more

0🍴 0📅 2025年12月26日
GitHubで見るManusで実行

SKILL.md


name: caching-optimizer description: "Optimize caching strategies for performance. Use when analyzing cache effectiveness, implementing multi-layer caching, optimizing Redis/memory caches, or troubleshooting slow response times."

Caching Optimizer

Intelligent caching strategy optimization for applications and APIs

Quick Commands

# Analyze cache effectiveness
npx @j0kz/caching-optimizer analyze

# Generate caching strategy
npx @j0kz/caching-optimizer suggest --profile=api

# Clear and warm cache
npm run cache:clear && npm run cache:warm

# Monitor cache metrics
npx @j0kz/caching-optimizer monitor

Core Functionality

Key Features

  1. Cache Analysis: Hit/miss ratios and effectiveness
  2. Strategy Optimization: LRU, LFU, TTL recommendations
  3. Multi-Layer Caching: Memory, Redis, CDN coordination
  4. Cache Warming: Preload frequently accessed data
  5. Invalidation Strategies: Smart cache busting

Detailed Information

For comprehensive details, see:

cat .claude/skills/caching-optimizer/references/caching-patterns.md
cat .claude/skills/caching-optimizer/references/redis-optimization.md
cat .claude/skills/caching-optimizer/references/cdn-strategies.md

Usage Examples

Example 1: Implement Multi-Layer Cache

import { CachingOptimizer } from '@j0kz/caching-optimizer';

const optimizer = new CachingOptimizer({
  layers: [
    { type: 'memory', size: '100MB', ttl: 300 },
    { type: 'redis', size: '1GB', ttl: 3600 },
    { type: 'cdn', ttl: 86400 }
  ]
});

// Automatic layer selection
const data = await optimizer.get('user:123', async () => {
  return await fetchUserFromDB(123);
});

Example 2: Cache Effectiveness Analysis

const metrics = await optimizer.analyze({
  period: '24h',
  breakdown: true
});

console.log(`Hit Rate: ${metrics.hitRate}%`);
console.log(`Miss Rate: ${metrics.missRate}%`);
console.log(`Eviction Rate: ${metrics.evictionRate}%`);

// Get recommendations
const suggestions = optimizer.suggest(metrics);
suggestions.forEach(s => console.log(s));

Caching Strategies

Common Patterns

  1. Cache-Aside (Lazy Loading)

    const data = cache.get(key) || await loadAndCache(key);
    
  2. Write-Through

    await Promise.all([
      cache.set(key, data),
      database.save(key, data)
    ]);
    
  3. Write-Behind (Write-Back)

    cache.set(key, data);
    queue.push({ action: 'save', key, data });
    

Cache Keys Strategy

// Hierarchical keys for batch invalidation
const keyPatterns = {
  user: 'user:{id}',
  userPosts: 'user:{userId}:posts',
  post: 'post:{id}',
  postComments: 'post:{postId}:comments:{page}'
};

Configuration

{
  "caching-optimizer": {
    "default": {
      "strategy": "lru",
      "maxSize": "512MB",
      "ttl": 3600,
      "compression": true
    },
    "layers": {
      "memory": {
        "enabled": true,
        "maxSize": "128MB"
      },
      "redis": {
        "enabled": true,
        "cluster": false,
        "db": 0
      },
      "cdn": {
        "enabled": true,
        "provider": "cloudflare"
      }
    },
    "monitoring": {
      "metrics": ["hitRate", "missRate", "latency"],
      "alertThreshold": {
        "hitRate": 0.8,
        "latency": 100
      }
    }
  }
}

Cache Invalidation

// Tag-based invalidation
await optimizer.tag(['user:123', 'posts']).set(key, data);
await optimizer.invalidateTag('user:123');

// Pattern-based invalidation
await optimizer.invalidatePattern('user:123:*');

// Time-based invalidation
await optimizer.set(key, data, { ttl: 3600, slide: true });

Notes

  • Supports Redis, Memcached, and in-memory caching
  • Automatic cache stampede prevention
  • Compression for large values
  • Distributed caching support for microservices

スコア

総合スコア

70/100

リポジトリの品質指標に基づく評価

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

+10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

レビュー

💬

レビュー機能は近日公開予定です