Go In-Memory Caching (samber/hot)

•
2.0k
•

Implements high-performance, type-safe in-memory caching in Go using advanced eviction algorithms and automated loader patterns.

This skill empowers Claude to design and implement sophisticated in-memory caching strategies for Go applications using the samber/hot library. It provides expert guidance on selecting between nine distinct eviction algorithms—including W-TinyLFU, S3FIFO, and ARC—based on specific workload access patterns. Beyond basic storage, the skill handles production-critical patterns such as read-through loaders with singleflight deduplication, TTL jitter to prevent thundering herds, Prometheus metrics integration, and memory-safe capacity sizing, making it essential for optimizing high-concurrency Go services.

Key Features

01Support for 9 eviction algorithms including W-TinyLFU, S3FIFO, LRU, and ARC
02Advanced TTL management with background janitors, jitter, and stale-while-revalidate
03Built-in Prometheus metrics integration for real-time hit rate and latency monitoring
04Automated read-through loaders with singleflight deduplication to prevent cache stampedes
051,998 GitHub stars
06Thread-safe implementation with optional sharding and copy-on-read/write for mutable data

Use Cases

01Optimizing microservice performance with memory-budgeted working set caches
02Reducing database latency by caching medium-to-low cardinality resources at high frequency
03Implementing robust session or configuration caching with automatic background refresh