golang-samber-hot

Implement in-memory caching in Go with samber/hot eviction algorithms and TTL.

Updated Apr 24, 2026
One-click install
npx skills add https://github.com/Utchash007/TermTales --skill golang-samber-hot-utchash007
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-samber-hot
Source: https://github.com/Utchash007/TermTales/tree/main/.agents/skills/golang-samber-hot
Command: npx skills add https://github.com/Utchash007/TermTales --skill golang-samber-hot-utchash007

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

In-memory caching for Go applications to reduce latency and backend pressure by using samber/hot with multiple eviction strategies, TTL, loader support, sharding, stale-while-revalidate, missing-key caching, and Prometheus metrics.

Core Features & Use Cases

  • Eviction algorithms: LRU, LFU, TinyLFU, W-TinyLFU, S3FIFO, ARC, TwoQueue, SIEVE, FIFO
  • TTL support and background janitor cleanup
  • Loader pattern with singleflight deduplication and optional revalidation
  • Sharding to scale concurrency and reduce lock contention
  • Missing-key caching (dedicated or shared)
  • Prometheus metrics integration for observability
  • Detailed usage patterns and production scenarios are documented in the references

Quick Start

Create a Go in-memory cache with samber/hot by calling hot.NewHotCache with hot.WTinyLFU, configure a TTL and janitor, then Build().

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 to reduce backend load?

To implement an in-memory cache in Go, use samber/hot by calling hot.NewHotCache with an eviction algorithm like W-TinyLFU, configure a TTL and janitor, then call Build() to reduce backend load and latency.

What eviction algorithms can I use for a Go cache?

Go caching with samber/hot supports LRU, LFU, TinyLFU, W-TinyLFU, S3FIFO, ARC, TwoQueue, SIEVE, and FIFO eviction algorithms to optimize memory usage across different access patterns.

How does the loader pattern work for Go in-memory caching?

The loader pattern for Go in-memory caching uses singleflight deduplication to prevent thundering herds, with optional revalidation to refresh stale entries in the background without blocking reads.

Can I scale Go cache concurrency with sharding?

Yes, you can scale Go cache concurrency by configuring sharding in samber/hot, which distributes keys across multiple internal cache instances to significantly reduce lock contention under high throughput.

How do I expose Prometheus metrics for a Go cache?

You can expose Prometheus metrics for a Go cache by enabling the built-in metrics integration in samber/hot, which provides observability into cache hits, misses, and eviction counts for production monitoring.

Does Go caching support missing-key caching to prevent cache penetration?

Yes, samber/hot supports missing-key caching using dedicated or shared configurations to store empty results, preventing cache penetration from repeated queries for non-existent keys.