golang-samber-hot

Configure samber/hot in-memory caching workflows for Go services.

2|Updated Mar 13, 2023
One-click install
npx skills add https://github.com/haipham22/golang-sample --skill golang-samber-hot-haipham22
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-samber-hot
Source: https://github.com/haipham22/golang-sample/tree/main/.agents/skills/golang-samber-hot
Command: npx skills add https://github.com/haipham22/golang-sample --skill golang-samber-hot-haipham22

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps you design and implement production-grade in-memory caching in Go with the samber/hot library, avoiding common mistakes that cause poor hit rates, stale data, runtime panics, and lock contention.

Core Features & Use Cases

  • Algorithm Selection: Choose the right eviction strategy for the workload, from mixed-access defaults to stable frequency-heavy caches and scan-resistant patterns.
  • Production Cache Setup: Configure TTL, janitor cleanup, loaders, negative caching, sharding, warm-up, copy semantics, and Prometheus metrics in the correct builder chain.
  • Operational Safety: Prevent issues like missing-cache panics, invalid WithoutLocking and Janitor combinations, loader-chain misunderstandings, and unsafe mutable value handling.
  • Use Case: A Go API can use this Skill to build a cache for user profiles, DNS records, product data, or configuration lookups with the right eviction policy and monitoring from the start.

Quick Start

Ask the assistant to build a samber/hot cache for your Go service with the correct eviction algorithm, TTL, janitor cleanup, and any loaders or monitoring you need.

Frequently Asked Questions about golang-samber-hot

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

FAQPage Schema
How do I configure a samber/hot cache in Go to avoid runtime panics and stale data?

To configure a Go in-memory cache with samber/hot safely, you must use the correct builder chain for TTL handling, janitor cleanup, and eviction algorithms while respecting safety constraints like WithoutLocking combinations to prevent runtime panics and stale data.

What is the best way to choose an eviction algorithm for a Go in-memory cache?

Choosing a Go cache eviction algorithm depends on your workload: use mixed-access defaults for general use, frequency-heavy algorithms for stable items, and scan-resistant patterns for large scans. Matching the eviction strategy to access patterns maximizes cache hit rates.

How do I set up loaders and negative caching for a Go API cache?

Set up Go cache loaders and negative caching by chaining loader functions during cache initialization to fetch missing data and store empty results, preventing repeated expensive lookups for non-existent keys in your Go API.

Does samber/hot support Prometheus monitoring and cache sharding for production Go services?

Yes, samber/hot supports Prometheus monitoring and cache sharding for production Go services. You can integrate Prometheus metrics and configure sharding in the builder chain to reduce concurrency contention and track cache performance.

Why does my Go cache experience lock contention during high-concurrency access?

Go cache lock contention often occurs when sharding is not configured or unsafe mutable values are handled without copy semantics. Enabling sharding distributes lock access across multiple cache instances, reducing concurrency contention.

Can I use cache warm-up and revalidation with samber/hot in Go?

Yes, you can use cache warm-up and revalidation with samber/hot in Go. Configuring warm-up pre-loads essential data into the cache, while revalidation ensures data freshness by checking TTL constraints before serving stale values.