golang-samber-hot

Configure samber/hot in-memory caching with eviction algorithms and TTL settings.

Updated May 28, 2026
One-click install
npx skills add https://github.com/vanstinator/semantic-search --skill golang-samber-hot-vanstinator
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-samber-hot
Source: https://github.com/vanstinator/semantic-search/tree/main/.agents/skills/golang-samber-hot
Command: npx skills add https://github.com/vanstinator/semantic-search --skill golang-samber-hot-vanstinator

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It helps Go engineers design high-performance in-memory caching with samber/hot by selecting an eviction strategy, configuring TTL and loader behavior, and avoiding common runtime and correctness pitfalls.

Core Features & Use Cases

  • Eviction algorithm selection (LRU/LFU/TinyLFU/W-TinyLFU/ARC/S3FIFO/SIEVE/TwoQueue/FIFO): Choose based on mixed versus stable access patterns and scan resistance needs.
  • TTL, jitter, and background expiration (Janitor): Prevent stale data and reduce thundering herd effects.
  • Loader patterns with singleflight deduplication + negative caching: Use WithLoaders to batch fetch on misses and optionally cache missing keys safely.
  • Stale-while-revalidate and error policy controls: Serve stale data while refreshing asynchronously, with KeepOnError or DropOnError.
  • Production hardening: Sharding to reduce lock contention, copy-on-read/write for mutable values, and Prometheus metrics for monitoring.

Quick Start

Use a W-TinyLFU cache with TTL, janitor cleanup, and Prometheus metrics, then add a loader function to batch-fetch missing keys safely when the cache expires.

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 effects when refreshing an in-memory cache in Go?

To prevent thundering herd effects in an in-memory cache, configure TTL with jitter and use background expiration via the Janitor lifecycle to stagger cache invalidations and reduce synchronized load spikes.

What is the best way to batch fetch missing keys in a Go read-through cache?

The best way to batch fetch missing keys in a read-through cache is using loader functions with singleflight deduplication to collapse concurrent miss requests into a single fetch operation.

How do I choose an eviction algorithm for a Go in-memory cache?

Choose an eviction algorithm based on your access patterns: select LFU for stable frequencies, LRU for mixed recency, W-TinyLFU for scan resistance, or ARC and SIEVE for dynamic workload adaptation.

Can I serve stale data while asynchronously refreshing a Go cache?

Yes, you can serve stale data while asynchronously refreshing a Go cache by enabling stale-while-revalidate strategies, configuring error policies like KeepOnError to maintain availability during backend failures.

How do I avoid panics when caching missing keys in a Go application?

To avoid panics when caching missing keys in a Go application, configure optional missing-key settings within your loader chaining semantics to safely handle negative caching of absent values.

How do I reduce lock contention in a high-frequency Go in-memory cache?

To reduce lock contention in a high-frequency Go in-memory cache, implement sharding across multiple cache instances and apply copy-on-read/write semantics to isolate mutable values safely.