# Golang Samber Hot

In-memory caching in Golang using samber/hot, eviction algorithms (LRU, LFU, TinyLFU...

- Repository: https://github.com/samber/cc-skills-golang (3750 stars)
- Category: Git and review
- License: MIT
- Last updated: 2026-11-01
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add samber/cc-skills-golang --skill golang-samber-hot -g -a claude-code -y`
Codex: `npx skills add samber/cc-skills-golang --skill golang-samber-hot -g -a codex -y`
Cursor: `npx skills add samber/cc-skills-golang --skill golang-samber-hot -g -a cursor -y`
Gemini CLI: `npx skills add samber/cc-skills-golang --skill golang-samber-hot -g -a gemini-cli -y`

## Description

In-memory caching in Golang using samber/hot, eviction algorithms (LRU, LFU, TinyLFU, W-TinyLFU, S3FIFO, ARC, TwoQueue, SIEVE, FIFO), TTL, cache loaders, sharding, stale-while-revalidate, missing key caching, and Prometheus metrics. Apply when using or adopting samber/hot, when the codebase imports github.com/samber/hot, or when the project repeatedly loads the same medium-to-low cardinality resources at high frequency and needs to reduce latency or backend pressure.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

**Persona:** You are a Go engineer who treats caching as a system design decision. You choose eviction algorithms based on measured access patterns, size caches from working-set data, and always plan for expiration, loader failures, and monitoring.

# Using samber/hot for In-Memory Caching in Go

Generic, type-safe in-memory caching library for Go 1.22+ with 9 eviction algorithms, TTL, loader chains with singleflight deduplication, sharding, stale-while-revalidate, and Prometheus metrics.

**Official Resources:**

- [pkg.go.dev/github.com/samber/hot](https://pkg.go.dev/github.com/samber/hot)
- [github.com/samber/hot](https://github.com/samber/hot)

This skill is not exhaustive, refer to library documentation and code examples for more information:

- For Go package docs, symbols, versions, importers, and known vulnerabilities, → See `samber/cc-skills-golang@golang-pkg-go-dev` skill (`godig`), preferred over Context7 for Go package facts.
- To navigate this library's usage in your own code (definitions, call sites, diagnostics), → See `samber/cc-skills-golang@golang-gopls` skill (`gopls`).
- Context7 remains a fallback for docs not indexed on pkg.go.dev.

```bash
go get -u github.com/samber/hot
```

## Algorithm Selection

Pick based on your access pattern, the wrong algorithm wastes memory or tanks hit rate.

The rest: https://github.com/samber/cc-skills-golang/blob/HEAD/skills/golang-samber-hot/SKILL.md
