golang-samber-hot

Configure samber/hot caches in Go with eviction algorithms, TTLs, and Prometheus metrics.

Updated Mar 29, 2026
One-click install
npx skills add https://github.com/osmanozen/go-commerce --skill golang-samber-hot-osmanozen
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-samber-hot
Source: https://github.com/osmanozen/go-commerce/tree/main/.agents/skills/golang-samber-hot
Command: npx skills add https://github.com/osmanozen/go-commerce --skill golang-samber-hot-osmanozen

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

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.

Frequently Asked Questions about golang-samber-hot

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

FAQPage Schema
How do I prevent thundering herd problems in Go in-memory cache implementations?

Prevent thundering herd issues in Go in-memory caches by using loader chains with singleflight to deduplicate concurrent loader calls and applying TTL jitter to stagger expiration times across keys.

Which eviction algorithm should I use for a Go cache with mixed access patterns?

For mixed access patterns, choose among LRU, LFU, TinyLFU, W-TinyLFU, S3FIFO, ARC, TwoQueue, SIEVE, or FIFO eviction algorithms to match your specific Go workload's memory and latency requirements.

How do I reduce lock contention in high-concurrency Go caching workloads?

Reduce lock contention in high-concurrency Go caching workloads by configuring sharding, which splits the cache into independent segments to minimize multi-core lock collisions during read and write operations.

Can I serve stale cache data while refreshing in the background in Go services?

Yes, you can serve stale cache data while refreshing in the background using the stale-while-revalidate pattern, which allows Go services to return existing data immediately while a background process fetches updated values.

How do I monitor Go cache hit rate and eviction metrics with Prometheus?

Monitor Go cache hit rate and eviction metrics with Prometheus by integrating built-in metrics collection that tracks cache operability, latency, and eviction events directly through a fluent builder configuration.

What is the best way to balance latency and memory usage for Go service caching?

Balance latency and memory usage by configuring samber/hot with appropriate eviction algorithms, per-cache TTL, and janitor routines to keep memory fresh while maintaining high throughput for Go services.