View Source Cachex.Stats (Cachex v4.0.3)

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.

Summary

Functions

Retrieves the latest statistics for a cache.

Functions

@spec for_cache(cache :: Cachex.t()) :: {:ok, map()} | {:error, atom()}

Retrieves the latest statistics for a cache.