What problem does it solve?
This Skill helps you design and implement high-performance in-memory caching in Go with correct eviction, TTL expiration, and safe loader behavior to reduce backend load and latency.
Core Features & Use Cases
- Eviction algorithm selection: Choose the right strategy (W-TinyLFU, LRU, LFU, TinyLFU, S3FIFO, ARC, TwoQueue, SIEVE, FIFO) based on access patterns to maximize hit rate.
- TTL and production hardening: Configure TTL, optional jitter, and background janitor cleanup to prevent stale data from lingering.
- Loader patterns and operational safety: Use
WithLoaders for read-through caching with built-in singleflight deduplication, plus stale-while-revalidate via WithRevalidation.
- Concurrency and correctness: Apply sharding to reduce contention and use Copy-on-Read/Write when cached values are mutable pointers/slices/maps.
- Monitoring and capacity planning: Enable Prometheus metrics and size caches using working-set/memory budget guidance.
Quick Start
Use the golang-samber-hot skill to configure a samber/hot cache with W-TinyLFU, a TTL, janitor cleanup, and a loader that batch-fetches missing keys while deduplicating concurrent requests.