ShieldedCache v2.1.1 ShieldedCache behaviour View Source
ShieldedCache
ShieldedCache is a caching module for Elixir.
What makes it special?
It enables a type of CDN Shielding on your cache that allows you to return stale results while simultaneously refreshing your data. This allows you to always return data to your client incredibly fast after the first request is made, while still refreshing data in an async way to keep subsequent requests fresh.
Callbacks
fetch/1: Executes the cache request and fetches the datakey/1: Generates a key out of the cache request
Overrideable Functions
key/1: Generates a key from a cache requestpre_get_side_effect/1: Creates a side effect before the get happens in the cachepost_get_side_effect/1: Creates a side effect after the get happens in the cachepre_fetch_side_effect/1: Creates a side effect before the fetch happens in the cachepost_fetch_side_effect/1: Creates a side effect after the fetch happens in the cacheexpired_side_effect/1: Creates a side effect when an expired value is returned from the cachefirst_fetch_side_effect/1: Creates a side effect on the first fetch of the request (when there is no previous value for this request in the cache)get_or_fetch_response_time_side_effect/2: Creates a side effect with the response time of theget_or_fetchfunction for the requestget_response_time_side_effect/2: Creates a side effect with the response time of thegetfunction for the requestfetch_response_time_side_effect/2: Creates a side effect with the response time of thefetchfunction for the requesthit_side_effect/1: Creates a side effect when a hit happens in the cachemiss_side_effect/1: Creates a side effect when a miss happens in the cachepost_fetch_transformation/1: Transforms the result from thefetchin some way when returned to the clientpost_get_transformation/1: Transforms the result from thegetin some way when returned to the clientretry_side_effect/1: Creates a side effect when a retry occurs in the task manager
Defaults
key/1: Uses theserialize!/1function to serialize whatever the cache request is into a key for the cache.pre_get_side_effect/1: Doesnilpost_get_side_effect/1: Doesnilpre_fetch_side_effect/1: Doesnilpost_fetch_side_effect/1: Doesnilexpired_side_effect/1: Doesnilfirst_fetch_side_effect/1: Doesnilget_or_fetch_response_time_side_effect/2: Doesnilget_response_time_side_effect/2: Doesnilfetch_response_time_side_effect/2: Doesnilhit_side_effect/1: Doesnilmiss_side_effect/1: Doesnilpost_fetch_transformation/1: Returns thefetchvalue with no changespost_get_transformation/1: Returns thegetvalue with no changesretry_side_effect/1: Doesnil
Link to this section Summary
Types
Return values of all functions for the cache
Link to this section Types
Return values of all functions for the cache
Link to this section Functions
Link to this section Callbacks
Link to this callback
fetch(cache_request)
View Source
fetch(cache_request :: term()) :: fetch_return()