ShieldedCache v1.1.1 ExampleShieldedCluster View Source

Link to this section Summary

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function expired_side_effect(cache_request) View Source
Link to this function fetch_response_time_side_effect(cache_request, response_time) View Source
Link to this function first_fetch_side_effect(cache_request) View Source
Link to this function get_or_fetch(cache_request) View Source
get_or_fetch(cache_request :: term()) ::
  {:ok, value :: any()} | {:error, reason :: any()}

get_or_fetch/1

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}.

Link to this function get_or_fetch!(cache_request) View Source
get_or_fetch!(cache_request :: term()) :: value :: any()

get_or_fetch!/1

Executes the get_or_fetch/1 function.

If the value is valid, returns the 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, raises the error.

Link to this function get_or_fetch_response_time_side_effect(cache_request, response_time) View Source
Link to this function get_response_time_side_effect(cache_request, response_time) View Source
Link to this function init(arg) View Source
init({cache_name :: module(), caching_module :: module()}) ::
  Supervisor.on_start()

init/1

Initializes the ShieldedCache Supervisor, which in turn starts the ShieldedCache.TaskManager module and the specified ShieldedCache.Cache caching module under the ShieldedCache supervision tree.

Link to this function key(cache_request) View Source
key(cache_request :: any()) :: key :: String.t()

key/1

Takes in a cache_request for data and runs the it through the serialize!/1 function to return a serialized key for use as a key in the cache.

Returns the serialized key or raises an error.

Link to this function post_fetch_side_effect(cache_request) View Source
Link to this function post_get_side_effect(cache_request) View Source
Link to this function pre_fetch_side_effect(cache_request) View Source
Link to this function pre_get_side_effect(cache_request) View Source
Link to this function start_link(opts \\ [cache_name: ExampleShieldedCluster, caching_module: ShieldedCache.Cache.RedisCluster, ttl: 5000]) View Source
start_link(opts :: Keyword.t()) :: Supervisor.on_start()

start_link/1

Starts the ShieldedCache Supervisor, which in turn starts the ShieldedCache.TaskManager module and the specified ShieldedCache.Cache caching module under the ShieldedCache supervision tree.