ShieldedCache v1.4.0 ShieldedCache.Cache behaviour View Source
ShieldedCache.Cache
The main behaviour module for a ShieldedCache module.
Callbacks
start_link/1
: Thestart_link
function for starting the module under theShieldedCache
Supervisorget/3
: Gets a valueset/4
: Sets a valueinvalidate/2
: Invalidates a value in the cacheserialize/1
: Serializes a value before saving it to the cachedeserialize/1
: Deserializes a value before returning it to the client
Defaults
key/1
: Uses theserialize!/1
function to serialize whatever the cache request is into a key for the cache.serialize/1
: Uses a simple JSON Encoder to encode the value as a Stringdeserialize/1
: Uses a simple JSON Decoder to decode the value to a usable data structure
Link to this section Summary
Types
Return values of all functions for the cache
Return values of deserialize
functions
Return values of serialize
functions
Functions
is_cache_module/1
Link to this section Types
Return values of all functions for the cache
Return values of deserialize
functions
Return values of serialize
functions
Link to this section Functions
The default deserializer, which uses a simple JSON Decoder to decode the value to the corresponding object.
Return {:ok, value}
or {:error, reason}
.
The default serializer, which uses a simple JSON Encoder to encode the value as a String.
Return {:ok, value}
or {:error, reason}
.
Link to this function
is_cache_module?(module)
View Source
is_cache_module?(module :: term()) :: true | false
is_cache_module/1
A utility function to determine if the provided argument is a module
and if it implements the ShieldedCache.Cache
behaviour.
Link to this section Callbacks
Link to this callback
deserialize(serialized_value)
View Source
deserialize(serialized_value :: String.t()) :: on_deserialize()
Link to this callback
get(caching_module_name, key, ttl, compressed)
View Source
get( caching_module_name :: atom(), key :: String.t(), ttl :: non_neg_integer(), compressed :: boolean() ) :: cache_return()
Link to this callback
invalidate(caching_module_name, key)
View Source
invalidate(caching_module_name :: atom(), key :: String.t()) :: cache_return()
Link to this callback
set(caching_module_name, key, value, ttl, compressed)
View Source
set( caching_module_name :: atom(), key :: String.t(), value :: any(), ttl :: non_neg_integer(), compressed :: boolean() ) :: cache_return()