command
Version:
v1.0.1
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
¶
Chain Cache Example
Demonstrates ChainCache[T] — multi-layer caching with automatic backfill.
What it shows
- Building a two-layer cache: L1 (small, fast) + L2 (larger, slower)
Set writes to all layers simultaneously
Get tries L1 first; on miss it falls through to L2 and backfills L1 asynchronously
Delete removes from all layers
GetLayers() to inspect the layer stack
Production pattern
Replace the L2 in-memory store with a Redis store:
redisClient, _ := rueidis.NewClient(rueidis.ClientOption{
InitAddress: []string{"localhost:6379"},
})
redisStore, _ := redis.New(redis.Config{Client: redisClient})
l2 := cache.New[Session](redisStore, cache.WithTTL(10*time.Minute))
Run
go run ./examples/chain/
Documentation
¶
Package main demonstrates multi-layer caching with ChainCache (L1 memory + L2 memory).
In production you would replace the L2 memory store with a Redis store.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.