Skip to main content

Module global

Module global 

Source
Expand description

Process-global default cache store, built once from config at boot.

Mirrors doido-model’s connection pool: init builds the store described by the current environment’s cache config and installs it; handlers read it via store. Apps that want several named stores can still use crate::CacheRegistry directly.

Functions§

init
Builds the cache store from config/<env>.yml and installs it as the global default, returning a handle. Idempotent: if already initialised, the existing store is returned and the freshly built one discarded. Call once at boot.
set_store
Installs an already-built store as the global default (e.g. in tests). Returns Err with the store back if one was already installed.
store
Returns the global cache store, panicking if init/set_store was never called. Use from request handlers where boot is guaranteed to have run.
try_store
Returns the global cache store if installed, else None.