golang-samber-hot

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

Updated May 30, 2026
One-click install
npx skills add https://github.com/ozan-fn/mqtt-capture --skill golang-samber-hot-ozan-fn
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-samber-hot
Source: https://github.com/ozan-fn/mqtt-capture/tree/main/.agents/skills/golang-samber-hot
Command: npx skills add https://github.com/ozan-fn/mqtt-capture --skill golang-samber-hot-ozan-fn

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve?

This Skill solves the challenge of efficient in-memory caching in Golang by utilizing the samber/hot library, enabling developers to implement caching strategies that enhance application performance and scalability.

Core Features & Use Cases

  • Eviction Algorithms: Offers 9 different eviction algorithms including LRU, LFU, and TinyLFU for varying access patterns.
  • TTL & Loaders: Allows setting Time To Live for cache entries and uses loader patterns to handle cache misses with singleflight deduplication.
  • Use Case: A Golang developer needs to cache database results frequently accessed by multiple goroutines to reduce database load and improve application response times.

Quick Start

Implement caching in your Golang application with the following command:

go get -u github.com/samber/hot

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 load?

In-memory caching in Golang can be implemented using the samber/hot library to handle resource loading with frequency-based eviction algorithms and TTL management. It provides read-through caching via loaders to efficiently reduce database load.

What eviction algorithms are available for Golang in-memory caching with samber/hot?

The samber/hot library offers 9 different eviction algorithms for in-memory caching, including LRU, LFU, and TinyLFU. These algorithms accommodate varying access patterns to optimize cache hit rates for medium-to-low cardinality resources.

How does read-through caching handle cache misses in concurrent Golang applications?

Read-through caching handles cache misses in Golang by using a loader pattern with singleflight deduplication. This mechanism prevents multiple goroutines from simultaneously fetching the same missing resource, reducing redundant database queries.

Can I set a Time To Live for cache entries in a Golang application?

Yes, you can set a Time To Live (TTL) for cache entries in a Golang application. The samber/hot library allows developers to configure TTL management to automatically expire stale cache entries.

When should I use frequency-based eviction algorithms like TinyLFU over LRU?

Frequency-based eviction algorithms like TinyLFU should be used over LRU when your Golang application exhibits access patterns favoring frequently accessed items rather than recently accessed ones, optimizing medium-to-low cardinality resource loading.

Do I need external dependencies to use samber/hot for in-memory caching in Golang?

No external dependencies are required beyond the library itself. You can install samber/hot directly via the go get command to start implementing in-memory caching, TTL management, and read-through loaders in your Golang application.