スキル一覧に戻る
JasonPaff

caching

by JasonPaff

Website for Bobblehead Collectors

2🍴 0📅 2026年1月19日
GitHubで見るManusで実行

SKILL.md


name: caching description: Enforces project caching conventions when implementing cache layers using React cache(), Next.js unstable_cache, Upstash Redis, and Cloudinary. This skill ensures consistent patterns for cache keys, tags, TTL configuration, cache invalidation, and domain-specific CacheService helpers.

Caching Skill

Purpose

This skill enforces the project caching conventions automatically during cache implementation. It ensures consistent patterns across the 4-layer caching strategy:

  1. React cache() - Same-request deduplication (e.g., getCurrentClerkUserId, getOptionalUserId)
  2. Next.js unstable_cache() - Cross-request caching with tag-based invalidation (primary)
  3. Upstash Redis - High-traffic public data, distributed locks, rate limiting, view tracking
  4. Cloudinary - Image transformation and CDN-level caching

Activation

This skill activates when:

  • Working with CacheService domain-specific helpers (.bobbleheads, .collections, .users, .search, .redisSearch, .analytics, .featured)
  • Implementing cached data fetching in facades
  • Setting up cache invalidation after mutations using CacheRevalidationService
  • Working with Redis operations via RedisOperations class
  • Using REDIS_KEYS for view tracking, locks, or rate limiting
  • Configuring cache tags and TTL values
  • Using CACHE_KEYS, CACHE_CONFIG, REDIS_TTL, or CacheTagGenerators
  • Implementing request-level deduplication with React cache()

Workflow

  1. Detect caching work (imports from CacheService, CacheRevalidationService, CACHE_KEYS, or CacheTagGenerators)
  2. Load references/Caching-Conventions.md
  3. Generate/modify code following all conventions
  4. Scan for violations of caching patterns
  5. Auto-fix all violations (no permission needed)
  6. Report fixes applied

Key Patterns

CacheService Domain Helpers

  • Use CacheService.bobbleheads.{method}() for bobblehead caching
  • Use CacheService.collections.{method}() for collection caching
  • Use CacheService.users.{method}() for user caching
  • Use CacheService.search.{method}() for search caching (Next.js unstable_cache)
  • Use CacheService.redisSearch.{method}() for high-traffic public search (Redis)
  • Use CacheService.analytics.{method}() for analytics caching
  • Use CacheService.featured.{method}() for featured content caching

Cache Invalidation

  • Use CacheRevalidationService.{domain}.on{Operation}() for coordinated invalidation
  • Use CacheService.invalidateByTag() for direct tag-based invalidation
  • Always invalidate cache after mutations in server actions
  • Check RevalidationResult.isSuccess and log failures to Sentry as warnings

Constants and Utilities

  • Use CACHE_KEYS.{DOMAIN}.{METHOD}() for cache key generation
  • Use CacheTagGenerators.{domain}.{method}() for tag generation
  • Use CACHE_CONFIG.TTL.{LEVEL} for TTL values:
    • REALTIME (30s), SHORT (5 min), MEDIUM (30 min), LONG (1 hr)
    • EXTENDED (4 hr), PUBLIC_SEARCH (10 min), DAILY (24 hr), WEEKLY (7 days)
  • Use REDIS_KEYS.{NAMESPACE}.{METHOD}() for Redis-specific keys (VIEW_TRACKING, LOCKS, RATE_LIMIT)
  • Use REDIS_TTL.{CATEGORY} for Redis-specific TTL values
  • Use createHashFromObject() for generating option hashes in cache keys

Usage Pattern Reference

Use CaseCacheService HelperInvalidation Service
Bobblehead by IDCacheService.bobbleheads.byId()CacheRevalidationService.bobbleheads.onUpdate()
Collection listCacheService.collections.byUser()CacheRevalidationService.collections.onCreate()
User profileCacheService.users.profile()CacheRevalidationService.users.onProfileUpdate()
Public searchCacheService.redisSearch.publicDropdown()CacheService.search.invalidatePublic()
AnalyticsCacheService.analytics.viewCounts()CacheRevalidationService.analytics.onViewRecord()
Social (likes)Tag-based via CacheTagGeneratorsCacheRevalidationService.social.onLikeChange()
View trackingREDIS_KEYS.VIEW_TRACKING.* + Redis opsTTL-based expiry (no explicit invalidation)

Caching Layer Selection Guide

Use CaseRecommended LayerRationale
Same-request deduplicationReact cache()Prevents redundant calls within single render (implemented for auth)
Entity data (bobbleheads, collections)unstable_cacheTag-based invalidation, automatic revalidation
High-traffic public searchRedisDistributed, fast, handles scale
View tracking deduplicationRedisDistributed, TTL-based expiry
Rate limitingRedisDistributed counters, automatic TTL expiry
Distributed locksRedisPrevents concurrent updates
Image transformationsCloudinaryCDN-level caching, on-the-fly transforms

References

  • references/Caching-Conventions.md - Complete caching conventions

スコア

総合スコア

40/100

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

SKILL.md

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

+20
LICENSE

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

0/10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

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

0/5
Issue管理

オープンIssueが50未満

+5
言語

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

+5
タグ

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

0/5

レビュー

💬

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