cache-management

Implement read-through caching with SWR and event-driven invalidation for repositories.

5|Updated May 30, 2023
One-click install
npx skills add https://github.com/VilnaCRM-Org/core-service --skill cache-management
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: cache-management
Source: https://github.com/VilnaCRM-Org/core-service/tree/main/.claude/skills/cache-management
Command: npx skills add https://github.com/VilnaCRM-Org/core-service --skill cache-management

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Caching in complex systems often leads to stale data, brittle invalidation, and fragmented implementations. This Skill standardizes caching with policy-driven design, SWR patterns, and event-driven invalidation to keep data fresh while maximizing performance.

Core Features & Use Cases

  • Decorator pattern wrapping repositories to implement read-through caching
  • Centralized key generation via CacheKeyBuilder and tag-based invalidation
  • Stale-While-Revalidate (SWR) with best-effort cache operations and observability
  • Event-driven cache invalidation using domain events for decoupled workflows
  • Production and test cache configurations with proper pools and tags
  • Comprehensive unit/integration testing guidance to validate cache paths

Quick Start

Configure a CachedXxxRepository decorator, wire domain-event invalidation subscribers, and run the cache tests to verify SWR, TTLs, and tag-based invalidation work as intended.

Frequently Asked Questions about cache-management

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement read-through caching with SWR to reduce database load?▼

Read-through caching with SWR is implemented by wrapping repositories in a decorator pattern, serving stale data while revalidating in the background via best-effort operations to reduce database load.

What is the best way to invalidate stale cache data using domain events?▼

Cache invalidation using domain events decouples workflows by triggering tag-based invalidation through event subscribers, ensuring cached data remains consistent without direct dependencies.

How do I configure cache keys and TTLs for consistent query caching?▼

Cache keys and TTLs are configured centrally using a CacheKeyBuilder, standardizing policy-driven design across queries to maintain consistent expiration and reliable cache hits.

How do I test cache hits, misses, and invalidation across different scenarios?▼

Cache hits, misses, and invalidations are verified through comprehensive unit and integration testing guidance, utilizing production and test cache configurations with proper pools and tags.

Can I add observable logging to a decorator pattern cache without changing repository logic?▼

Yes, the decorator pattern wraps existing repositories to add SWR caching and observable logging without modifying core repository logic, providing visibility into cache operations.