View Source Cachex.Stats (Cachex v3.6.0)
Hook module to control the gathering of cache statistics.
This implementation of statistics tracking uses a hook to run asynchronously against a cache (so that it doesn't impact those who don't want it). It executes as a post hook and provides a solid example of what a hook can/should look like.
This hook has zero knowledge of the cache it belongs to; it keeps track of an
internal set of statistics based on the provided messages. This means that it
can also be mocked easily using raw server calls to handle_notify/3
.
Link to this section Summary
Functions
Determines if stats are enabled for a cache.
Locates a stats hook for a cache, if enabled.
Retrieves the latest statistics for a cache.
Link to this section Functions
@spec enabled?(Spec.cache()) :: boolean()
Determines if stats are enabled for a cache.
@spec locate(Spec.cache()) :: Spec.hook() | nil
Locates a stats hook for a cache, if enabled.
@spec retrieve(Spec.cache()) :: %{}
Retrieves the latest statistics for a cache.