Cachex v3.1.3 Cachex.Stats View Source

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

Returns a specification to start this module under a supervisor

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

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function enabled?(cache) View Source
enabled?(Spec.cache()) :: boolean()

Determines if stats are enabled for a cache.

Link to this function locate(arg) View Source
locate(Spec.cache()) :: Spec.hook() | nil

Locates a stats hook for a cache, if enabled.

Link to this function retrieve(cache) View Source
retrieve(Spec.cache()) :: %{}

Retrieves the latest statistics for a cache.