Back to Skills

golang-samber-hot

In-memory caching in Golang using samber/hot — eviction algorithms (LRU, LFU, TinyLFU, W-TinyLFU, S3FIFO, ARC, TwoQueue, SIEVE, FIFO), TTL, cache loaders, sharding, stale-while-revalidate, missing key caching, and Prometheus metrics. Apply when using or adopting samber/hot, when the codebase imports github.com/samber/hot, or when the project repeatedly loads the same medium-to-low cardinality resources at high frequency and needs to reduce latency or backend pressure.

1,807stars118forksUpdated 5/24/2026

Security Assessment

Safe(100/100)
Security Score100/100

About golang-samber-hot

This skill provides guidance for using samber/hot, a type-safe in-memory caching library for Go designed to reduce latency and backend load in applications that repeatedly access the same medium-to-low cardinality data. It focuses on helping developers adopt caching as a deliberate system design decision rather than an implementation detail, emphasizing correct eviction strategy selection and operational awareness. The library supports Go 1.22+ and is intended for high-frequency workloads where repeated reads can be served from memory instead of hitting slower backend systems.

It offers a broad set of eviction algorithms including W-TinyLFU, LRU, LFU, TinyLFU, S3FIFO, ARC, TwoQueue, SIEVE, and FIFO, allowing optimization based on workload characteristics such as recency, frequency, or scan resistance. Additional capabilities include TTL-based expiration, cache loaders with singleflight-style deduplication for missing keys, cache sharding for scalability, stale-while-revalidate behavior to reduce cache stampedes, missing key caching to prevent repeated backend misses, and Prometheus metrics for observability. These features collectively support building robust caching layers that can be tuned for both performance and reliability.

Typical use cases include session caching, frequently accessed user or product data, DNS or lookup-style frequency-heavy datasets, and any service where backend calls are expensive or rate-limited. It is especially relevant for backend Go services handling high request throughput. The intended users are Go engineers and system designers who need fine-grained control over cache behavior and want to improve system responsiveness while reducing infrastructure pressure through intelligent in-memory caching strategies.

FAQ

What problem does samber/hot help solve?

It reduces repeated backend or database access by providing an in-memory caching layer for frequently accessed data, improving latency and lowering system load.

Which Go versions and environments are supported?

It is designed for Go 1.22+ and is intended for backend Go services where in-memory caching can be used to improve performance.

How do I choose the right eviction algorithm?

Start with W-TinyLFU as a general-purpose default. Other algorithms like LRU, LFU, ARC, or S3FIFO should be chosen based on whether your workload is dominated by recency, frequency, or scan resistance needs.

Does it handle expired or stale data?

Yes, it supports TTL-based expiration and stale-while-revalidate behavior to manage data freshness while avoiding cache stampedes.

What observability features are available?

It includes Prometheus metrics support to help monitor cache performance and behavior in production systems.

All Files

5 files
references/algorithm-guide.md8.5 KB
View
references/api-reference.md6.2 KB
View
SKILL.md7.3 KB
View
evals/evals.json16.2 KB
View
references/production-patterns.md6.7 KB
View

Install golang-samber-hot

Download and extract the skill files to your .claude/skills/ directory.

Quick Setup:

  1. Copy the skill folder to .claude/skills/
  2. Claude will automatically detect and use the skill