Cachex.Actions (Cachex v3.4.0) View Source
Parent actions module for cache interactions.
This module contains foundation actions required to implement cache actions,
such as typical CRUD style operations on cache entries. It also provides the
defaction/2 macro which enables command definition which injects notifications
for cache hooks.
Link to this section Summary
Functions
Normalizes a value into a Courier-friendly tagged Tuple.
Retrieves an entry from a cache.
Updates a collection of fields inside a cache entry.
Writes a new entry into a cache.
Returns the operation used for a write based on a prior value.
Link to this section Functions
Normalizes a value into a Courier-friendly tagged Tuple.
If the value is tagged with :commit, :ignore or :error,
it will be left alone; otherwise it will be wrapped and treated
as a :commit Tuple.
Specs
read(Spec.cache(), any()) :: Spec.entry() | nil
Retrieves an entry from a cache.
If the entry does not exist, a nil value will be returned. Likewise
if the entry has expired, we lazily remove it (if enabled) and return
a nil value.
This will return an instance of an entry record as defined in the main
Cachex.Spec module, rather than just the raw value.
Specs
Updates a collection of fields inside a cache entry.
This is done in a single call due to the use of :ets.update_element/3 which
allows multiple changes in a group. This will return a boolean to represent
whether the update was successful or not.
Note that updates are atomic; either all updates will take place, or none will.
Specs
write(Spec.cache(), [Spec.entry()]) :: {:ok, boolean()}
Writes a new entry into a cache.
Specs
Returns the operation used for a write based on a prior value.