Skip to main content

Module memory

Module memory 

Source
Expand description

The in-memory driver: the default, and the one tests use.

Entries live in a fixed set of shards, each behind its own RwLock. One global lock would serialise every cache read in the process — which for a web server means serialising every request — while sharding means two keys that hash differently never wait for each other.

Expired entries are removed on read (so a stale value is never returned even between sweeps) and by a periodic background sweep (so a key that is written once and never read again does not leak memory forever).

Structs§

MemoryStore
A process-local cache. Cloning shares one store, so it can be registered as application state and handed to every handler.