
Golang Samber Hot
Configure samber/hot in-memory caches with the right eviction algorithm, TTL, and janitor lifecycle for Go APIs.
Overview
golang-samber-hot is an agent skill for the Build phase that configures samber/hot caches with correct eviction algorithms, builder janitor hooks, and StopJanitor lifecycle in Go.
Install
npx skills add https://github.com/samber/cc-skills-golang --skill golang-samber-hotWhat is this skill?
- Defaults mixed workloads to hot.WTinyLFU instead of naive hot.LRU from generic cache intuition
- Uses hot.NewHotCache with generics, WithTTL, WithJanitor in builder chain, then Build()
- Requires defer cache.StopJanitor() after Build—not a separate post-build Janitor() call
- Guides LFU when access is stable power-law frequency (e.g. DNS hot domains) over W-TinyLFU
- Eval scenarios include 50k-entry TTL API cache and DNS power-law LFU selection
Adoption & trust: 3.4k installs on skills.sh; 2k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
Your Go agent scaffolds LRU caches, forgets StopJanitor, or uses W-TinyLFU where LFU fits a fixed heavy-hitters workload.
Who is it for?
Solo Go API builders adding bounded in-process caches for lookups with mixed or power-law access patterns.
Skip if: Distributed Redis-style caching, non-Go stacks, or teams that need cross-node invalidation rather than single-process hot caches.
When should I use this skill?
User implements or asks about github.com/samber/hot caches, eviction algorithm choice, or janitor lifecycle in Go.
What do I get? / Deliverables
You get a finalized hot.NewHotCache build with appropriate W-TinyLFU or LFU, TTL, in-builder WithJanitor, and deferred janitor stop safe for production APIs.
- Configured HotCache builder code with Build and StopJanitor
- Documented W-TinyLFU versus LFU rationale for the workload
Recommended Skills
Journey fit
How it compares
Go-specific samber/hot procedural skill—not a generic caching lecture or a cloud CDN integration.
Common Questions / FAQ
Who is golang-samber-hot for?
Indie and solo developers shipping Go web APIs or resolvers who want github.com/samber/hot configured with Samber-recommended defaults.
When should I use golang-samber-hot?
Use it in Build backend work when adding in-memory TTL caches, choosing W-TinyLFU versus LFU, or wiring janitor cleanup on hot caches.
Is golang-samber-hot safe to install?
It guides local in-process caching patterns; review the Security Audits panel on this Prism page for the source repo before enabling in agents with shell access.
SKILL.md
READMESKILL.md - Golang Samber Hot
[ { "id": 1, "name": "algorithm-selection-default", "description": "Tests whether the model recommends W-TinyLFU as default instead of LRU", "prompt": "I need an in-memory cache for my Go web API using samber/hot. It handles user profile lookups with mixed access patterns — some users are accessed frequently, others only occasionally. Set up a cache with 50k entries and 10-minute TTL.", "trap": "Without the skill, the model defaults to hot.LRU (the most well-known algorithm) instead of hot.WTinyLFU which handles mixed workloads better", "assertions": [ {"id": "1.1", "text": "Uses hot.WTinyLFU as the eviction algorithm (not hot.LRU)"}, {"id": "1.2", "text": "Uses hot.NewHotCache constructor with generic type parameters"}, {"id": "1.3", "text": "Chains .WithTTL(10 * time.Minute) or equivalent"}, {"id": "1.4", "text": "Chains .WithJanitor() in the builder (not calling cache.Janitor() separately after Build)"}, {"id": "1.5", "text": "Calls defer cache.StopJanitor() after Build()"}, {"id": "1.6", "text": "Calls .Build() to finalize the cache"} ] }, { "id": 2, "name": "algorithm-selection-frequency", "description": "For stable frequency-dominated workloads, LFU beats W-TinyLFU despite W-TinyLFU being the general default", "prompt": "I'm building a DNS resolver cache in Go with samber/hot. Lookups follow a heavy power-law distribution — a small set of domains (google.com, cloudflare.com) are looked up millions of times, while most domains are rare. The popularity rankings are very stable over time.\n\nA teammate says: 'The docs say W-TinyLFU is the general-purpose default that handles mixed workloads. We should always start with hot.WTinyLFU to avoid bike-shedding — you can always tune later.' Is this good advice for this specific use case? Which algorithm should I actually use?", "trap": "The teammate's advice sounds pragmatic — 'start with the default, tune later' is usually good. But the skill teaches that for stable frequency-dominated workloads (where popularity rankings don't shift), hot.LFU is superior to W-TinyLFU. LFU's known weakness (stale popular items never evict) is irrelevant when rankings are stable. The model should override the default recommendation.", "assertions": [ {"id": "2.1", "text": "Pushes back on the teammate — does NOT blindly apply hot.WTinyLFU when the workload is clearly stable-frequency-dominated"}, {"id": "2.2", "text": "Recommends hot.LFU as the correct algorithm: stable power-law distribution maps exactly to LFU's strength (keeping the most frequently accessed items)"}, {"id": "2.3", "text": "Explains why LFU's known weakness (stale popular items stuck in cache) does NOT apply here — popularity rankings are stable, so the stale-items problem doesn't manifest"}, {"id": "2.4", "text": "Correctly positions W-TinyLFU as 'general-purpose for unknown/shifting patterns' while LFU is 'optimal for known stable frequency patterns'"} ] }, { "id": 3, "name": "janitor-required", "description": "Tests whether the model correctly includes WithJanitor() — the most common mistake", "prompt": "Write a simple samber/hot cache in Go with a 5-minute TTL for caching API responses. Key is string, value is []byte.", "trap": "Without the skill, the model forgets WithJanitor() — expired entries stay in memory until algorithm eviction, silently serving stale data", "assertions": [ {"id": "3.1", "text": "Includes .WithJanitor() in the builder chain"}, {"id": "3.2", "text": "Includes defer cache.StopJanitor() for cleanup"}, {"id": "3.3", "text": "Uses .WithTTL() for expiration"}, {"id": "3.4", "text": "Does NOT call cache.Janitor() as a separate method after Build() — it should be chained in the builder"} ] }, { "id": 4, "name": "missing-cache-panic-prevention", "description": "Tests whether the model correctly enables missing cache bef