pay_day_loan v0.5.1 PayDayLoan.Backend behaviour
Defines the PDL backend behaviour.
The backend is responsible for allowing us to access the cached value
for a given key. PayDayLoan’s EtsBackend
module is used by default, and
is built with a process cache in mind. You could use the Backend
behaviour to implement, for example, a Redis or mnesia backend.
Summary
Callbacks
Delete a key from the cache
Retrieve a value from the cache
Should return a list of keys in the cache
Insert a value into the cache
Should execute a reduce operation over the key/value pairs in the cache
Called during supervisor initialization - use this callback to initialize
your backend if needed. Must return :ok
Should return the number of keys in the cache
Should return a list of values in the cache
Callbacks
Delete a key from the cache
Must return :ok
Retrieve a value from the cache
Should return {:error, :not_found}
if the value is not found and
{:ok, value}
otherwise.
Should return a list of keys in the cache
Insert a value into the cache
Must return :ok
reduce(PayDayLoan.t, acc0 :: term, reducer :: ({PayDayLoan.key, term}, term -> term)) :: term
Should execute a reduce operation over the key/value pairs in the cache.
The reducer function should take arguments in the form
({key, value}, accumulator)
and return the new accumulator value - i.e.,
it should operate as Enum.reduce/3
would when given a map.
Called during supervisor initialization - use this callback to initialize
your backend if needed. Must return :ok
.
Should return the number of keys in the cache
Should return a list of values in the cache