What problem does it solve?
In-memory caching is essential to reduce latency and load on backend services. This Skill provides a structured approach to using samber/hot for robust, scalable caches in Go, offering multiple eviction strategies and modern patterns like loaders, sharding, and stale-while-revalidate.
Core Features & Use Cases
-
Eviction algorithms: choose among LRU, LFU, TinyLFU, W-TinyLFU, S3FIFO, ARC, TwoQueue, SIEVE, FIFO to match workload.
-
TTL and expiration: configure per-cache TTL and jitter for thundering herd mitigation.
-
Loader chains with singleflight: prevent the thundering herd by deduplicating loader calls.
-
Sharding for concurrency: split cache to reduce lock contention on multi-core servers.
-
Stale-while-revalidate: serve stale data while refreshing in background.
-
Prometheus metrics: monitor hit rate, evictions, and latency for operability.
-
Use Case: When your Go service caches user sessions and catalog lookups with varying access patterns and you need high throughput and reliability.
Quick Start
Install and configure a hot cache with a suitable algorithm, TTL, and janitor to keep memory fresh.