Commanded.Middleware.Uniqueness.Adapter behaviour (Commanded Uniqueness Middleware v0.7.1) View Source
Provides uniqueness cache adapter behaviour.
Define options in config/config.exs as:
config :commanded_uniqueness_middleware,
adapter: Commanded.Middleware.Uniqueness.Adapter.Cachex,
# ttl: 60 minutes in seconds
ttl: 60 * 60,
use_command_as_partition: true
where:
:adapter
is an Uniqueness adapter implementedCommanded.Middleware.Uniqueness.Adapter
behavior,:ttl
is claimed value time-to-live,:use_command_as_partition
should be set to use each command module name as partition. If neither this nor:partition
option defined thenCommanded.Middleware.Uniqueness
value used as a partition name.
Link to this section Summary
Callbacks
Returns an adapter child_spec to inject into a supervisor tree
Claims an key
, value
, partition
set
or reports that this combination has already been claimed.
Claims an key
, value
, owner
, partition
set
or reports that this combination has already been claimed.
Releases a value record via key
, value
, owner
, partition
set
Releases a value record via key
, owner
, partition
set
Releases a value record via key
, value
, partition
set
Link to this section Functions
Specs
get() :: :atom | nil
Returns the current adapter or nil
Link to this section Callbacks
Specs
child_spec() :: Supervisor.child_spec()
Returns an adapter child_spec to inject into a supervisor tree
Specs
claim(key :: term(), value :: term(), partition :: term()) :: :ok | {:error, :already_exists} | {:error, :unknown_error}
Claims an key
, value
, partition
set
or reports that this combination has already been claimed.
Specs
claim(key :: term(), value :: term(), owner :: term(), partition :: term()) :: :ok | {:error, :already_exists} | {:error, :unknown_error}
Claims an key
, value
, owner
, partition
set
or reports that this combination has already been claimed.
If an key
, value
, owner
, partition
set has to be claimed
and an old value for the given owner exists it releases first.
Specs
release(key :: term(), value :: term(), owner :: term(), partition :: term()) :: :ok | {:error, :claimed_by_another_owner} | {:error, :unknown_error}
Releases a value record via key
, value
, owner
, partition
set
Specs
release_by_owner(key :: term(), owner :: term(), partition :: term()) :: :ok | {:error, :unknown_error}
Releases a value record via key
, owner
, partition
set
Specs
release_by_value(key :: term(), value :: term(), partition :: term()) :: :ok | {:error, :unknown_error}
Releases a value record via key
, value
, partition
set