ShieldedCache v1.2.2 ShieldedCache.Functions View Source

ShieldedCache.Functions

The cache functions for the ShieldedCache module. These are injected into every ShieldedCache instance, and give the module the functionality for get_or_fetch.

Link to this section Summary

Link to this section Functions

Link to this function get_or_fetch(cache_name, caching_module, caching_module_name, ttl, cache_request) View Source
get_or_fetch(
  cache_name :: atom() | module(),
  caching_module :: module(),
  caching_module_name :: atom() | module(),
  ttl :: non_neg_integer(),
  cache_request :: term()
) :: {:ok, value :: any()} | {:error, reason :: any()}

get_or_fetch/4

Gets the requested value.

If the value is valid, returns the {:ok, value}. If the value is expired, returns the expired_value and adds the cache_request that requires a refresh to the TaskManager. If there is an error, returns {:error, reason}.