darvaza.org/cache
Generic cache abstraction with TTL, stampede control, and pluggable backends.
Generic cache abstraction keyed by any comparable type. The
Cache interface
provides Get, Set, and Remove with per-entry expiration. Data
flows through a Sink abstraction — ByteSink for raw bytes,
GobSink[T] for Gob-encoded objects, or a custom SinkFn[T] built
from user-supplied encode/decode functions.
A Store manages named
cache namespaces with size limits and pluggable data loaders
(Getter[K]).
Backends§
| Backend | Module | Description |
|---|---|---|
| simplelru | Non-thread-safe LRU with TTL; evicts expired entries first | |
| memcache | Thread-safe in-memory cache with SingleFlight stampede prevention | |
| groupcache | Distributed caching via mailgun/groupcache with HTTP peer discovery | |
| protosink | TSink[T] implementation using Protocol Buffers encoding |
See also§
- DNS resolver (uses simplelru) — darvaza.org/resolver
- Structured logging — darvaza.org/slog