golang-samber-hot

Configure Golang in-memory caching with eviction algorithms, TTL, and sharding.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires samber/hot, and includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve?

This Skill addresses the challenge of managing in-memory caching for Golang applications, offering robust solutions with a variety of eviction algorithms to optimize performance and resource utilization.

Core Features & Use Cases

  • Multiple Eviction Algorithms: Provides LRU, LFU, TinyLFU, W-TinyLFU, S3FIFO, ARC, TwoQueue, SIEVE, and FIFO to handle diverse access patterns.
  • Time-to-Live (TTL): Enables automatic expiration of cached items after a specified duration.
  • Cache Loaders: Fetches missing keys using loaders and singleflight deduplication to optimize performance.
  • Sharding: Splits the cache into segments to reduce lock contention in high-concurrency scenarios.
  • Stale-While-Revalidate: Serves stale data while asynchronously refreshing to ensure continuous availability.
  • Use Case: Ideal for a project that uses Golang and needs to frequently access medium-to-low cardinality resources, such as database query results or configuration files.

Quick Start

Use the golang-samber-hot skill to cache your frequently accessed resources, improving application performance.

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 in-memory caching in Golang to reduce database query latency?

In-memory caching in Golang reduces latency by storing frequently accessed resources like database results in memory. This approach supports TTL, sharding, and multiple eviction algorithms to optimize performance and lower backend pressure.

What is the best eviction algorithm for Golang cache performance optimization?

The best eviction algorithm depends on your access patterns. Available options include LRU, LFU, TinyLFU, W-TinyLFU, S3FIFO, ARC, TwoQueue, SIEVE, and FIFO, allowing you to tailor cache performance to specific workloads.

How does sharding improve Golang in-memory cache performance in high concurrency scenarios?

Sharding improves Golang in-memory cache performance by splitting the cache into segments, which significantly reduces lock contention during high-concurrency access and ensures smoother throughput.

Does the samber/hot Golang caching library support stale-while-revalidate?

Yes, the samber/hot Golang caching library supports stale-while-revalidate. This mechanism serves stale data while asynchronously refreshing the cache in the background to ensure continuous application availability.

Can I use cache loaders to deduplicate missing key fetches in Golang?

Yes, you can use cache loaders with singleflight deduplication in Golang to fetch missing keys. This optimizes performance by preventing multiple concurrent requests from overwhelming the backend for the same resource.

Do I need a specific Go version to use samber/hot for in-memory caching?

Yes, you need Go 1.22 or higher to use samber/hot for in-memory caching. It is designed for Golang projects accessing medium-to-low cardinality resources like configuration files or database query results.