loader

command
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2026 License: MIT Imports: 7 Imported by: 0

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

Overview

Package main demonstrates the loader pattern with single-flight deduplication.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL