AbsintheCacheFairy.Behaviour behaviour (absinthe_cache_fairy v0.2.1)
Behaviour that the cache needs to conform to.
TODO: Write more docs
Link to this section Summary
Callbacks
Get the value for the given key from the cache.
Get the value for the given key from the cache. If there is no record with this
key, execute fun, store its value under the key key if and only if it is not
an error and return in. If there is more than one query for that key, fun
should be executed only once and the rest of the queries will wait until the result.
is ready.
Put a query document in the cache with the key as cache key.
Link to this section Types
cache()
@type cache() :: atom()
error()
@type error() :: String.t()
hash()
@type hash() :: String.t()
key()
@type key() :: hash() | {atom(), hash()} | {non_neg_integer(), non_neg_integer()}
size_type()
@type size_type() :: :megabytes
stored_value()
@type stored_value() :: any()
Link to this section Callbacks
clear_all(cache)
@callback clear_all(cache()) :: :ok
get(cache, hash)
Get the value for the given key from the cache.
@callback get_or_store(cache(), key(), (... -> any())) :: {:ok, stored_value()} | {:error, error()}
@callback get_or_store(cache(), key(), (... -> any()), (... -> any())) :: {:ok, stored_value()} | {:error, error()}
Get the value for the given key from the cache. If there is no record with this
key, execute fun, store its value under the key key if and only if it is not
an error and return in. If there is more than one query for that key, fun
should be executed only once and the rest of the queries will wait until the result.
is ready.
size(cache, size_type)
store(cache, key, stored_value)
@callback store(cache(), key(), stored_value()) :: :ok | {:error, error()}
Put a query document in the cache with the key as cache key.