golang-samber-hot

Create in-memory Go caches with configurable eviction algorithms and TTLs.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Many Go services need fast, safe in‑memory caching to reduce latency and backend load, but choosing the right eviction algorithm, handling expiration, and preventing thundering‑herd problems is complex.

Core Features & Use Cases

  • Algorithm selection: Choose from LRU, LFU, W‑TinyLFU, ARC, S3FIFO, and more based on workload patterns.
  • Loader & singleflight: Register loaders that automatically fetch missing keys with built‑in deduplication.
  • Production patterns: Missing‑key caching, stale‑while‑revalidate, sharding, copy‑on‑read/write, Prometheus metrics, warm‑up and graceful shutdown.
  • Use case example: Cache user profile objects in a high‑traffic API where some users are hot and others are accessed infrequently.

Quick Start

Ask the AI to create a hot cache with 10,000 capacity using the W‑TinyLFU algorithm and a 5‑minute TTL.

Frequently Asked Questions about golang-samber-hot

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

FAQPage Schema
How do I implement an in-memory cache in Go with W-TinyLFU eviction?

To implement an in-memory cache in Go with W-TinyLFU eviction, configure samber/hot with a specific capacity, TTL, and janitor cleanup. W-TinyLFU suits mixed recency and frequency workloads like user profile caches.

How does singleflight deduplication work with Go cache loaders?

Singleflight deduplication in Go cache loaders prevents thundering-herd problems by automatically fetching missing keys while collapsing concurrent requests into a single backend call.

Which cache eviction algorithm should I use in Go for high-frequency lookups?

For high-frequency lookups with mixed access patterns, W-TinyLFU or ARC are strong eviction algorithm choices in Go. LRU and LFU handle simpler recency or frequency workloads respectively.

Can I use Prometheus metrics with a Go in-memory cache?

Yes, you can integrate Prometheus metrics with a Go in-memory cache using samber/hot. It supports production patterns including Prometheus metrics, sharding, copy-on-read/write, and graceful shutdown.

How do I handle missing keys in a Go cache without overwhelming the backend?

Handle missing keys in a Go cache by enabling missing-key caching and stale-while-revalidate patterns. Registering loaders with built-in singleflight deduplication further prevents backend overload.

What are the limitations of using in-memory caching in Go services?

In-memory caching in Go is limited by available RAM and loses data on restart. It is not ideal for distributed environments requiring cross-node consistency without additional sharding or external synchronization.