command
Version:
v1.0.2
Opens a new window with list of versions in this module.
Published: Feb 18, 2026
License: MIT
Opens a new window with license information.
Imports: 7
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
¶
Loader Pattern Example
Demonstrates LoaderCache[T] — cache-aside with automatic loading and single-flight deduplication.
What it shows
- Creating a
LoaderCache[Product] via cache.NewLoader
GetOrLoad: returns cached value on hit, calls the loader on miss
- Single-flight deduplication: 5 concurrent requests for the same key trigger only one loader call
- Loader receives
context.Context and the cache key
Run
go run ./examples/loader/
Documentation
¶
Package main demonstrates the loader pattern with single-flight deduplication.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.