← All projects

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§

BackendModuleDescription
simplelruNon-thread-safe LRU with TTL; evicts expired entries first
memcacheThread-safe in-memory cache with SingleFlight stampede prevention
groupcacheDistributed caching via mailgun/groupcache with HTTP peer discovery
protosinkTSink[T] implementation using Protocol Buffers encoding

See also§