One-click install
npx skills add https://github.com/dmwin72015/netdisk --skill golang-samber-hot-dmwin72015
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-samber-hot
Source: https://github.com/dmwin72015/netdisk/tree/main/.agents/skills/golang-samber-hot
Command: npx skills add https://github.com/dmwin72015/netdisk --skill golang-samber-hot-dmwin72015

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps you design reliable in-memory caching in Go using samber/hot, preventing slowdowns from repeated medium-to-low cardinality lookups and reducing backend pressure.

Core Features & Use Cases

  • Eviction algorithm selection: Choose eviction strategies like LRU, LFU, TinyLFU, W-TinyLFU, S3FIFO, ARC, TwoQueue, SIEVE, and FIFO based on access patterns (and avoid common mismatches).
  • Correct expiration behavior: Configure TTL, jitter, background janitor cleanup, and stale-while-revalidate so cached data stays fresh.
  • Production-grade miss handling: Use loaders with built-in singleflight deduplication, loader chains, missing-key (negative) caching, and safe concurrency patterns (copy-on-read/write) with observability via Prometheus.

Quick Start

Use the golang-samber-hot skill to set up a samber/hot cache with W-TinyLFU, TTL plus WithJanitor, loader-based read-through with WithLoaders, and Prometheus metrics for a cache name like user_cache.

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 stale-while-revalidate and negative caching in a Go in-memory cache?

To implement stale-while-revalidate and negative caching in a Go in-memory cache, use samber/hot with WithRevalidation and WithMissingCache configurations. This keeps data fresh while caching missing keys to prevent repeated backend lookups.

What is the best eviction algorithm for high-concurrency Go caching workloads?

The best eviction algorithm for high-concurrency Go caching depends on access patterns; samber/hot supports LRU, LFU, TinyLFU, W-TinyLFU, S3FIFO, ARC, and SIEVE. W-TinyLFU often excels for mixed scan-heavy workloads.

How do I prevent cache stampede and deduplicate lookups in a Go application?

To prevent cache stampede and deduplicate concurrent lookups in a Go application, configure samber/hot WithLoaders with built-in singleflight semantics. This collapses parallel identical requests into a single backend fetch.

How do I safely handle mutable values and sharded access in an in-memory Go cache?

To safely handle mutable values and sharded access in an in-memory Go cache, enable WithSharding for high concurrency and WithCopyOnRead to prevent race conditions. This ensures data isolation across concurrent read operations.

Does samber/hot support Prometheus metrics and background janitor cleanup for TTL expiration?

Yes, samber/hot supports Prometheus metrics for cache observability and WithJanitor for background TTL cleanup. Configuring WithTTL with the janitor ensures automatic eviction of expired keys without blocking read operations.

When should I avoid using an in-memory caching strategy in Go?

You should avoid in-memory caching in Go for extremely high-cardinality datasets that exceed available RAM or when strict cross-instance consistency is required, as samber/hot is designed for local, medium-to-low cardinality lookups to reduce backend load.