Commanded Uniqueness Middleware v0.6.1 Commanded.Middleware.Uniqueness.Adapter behaviour 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:

Link to this section Summary

Functions

Returns the current adapter or nil

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

Link to this callback

claim(key, value, partition)

View Source

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.

Link to this callback

claim(key, value, owner, partition)

View Source

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.

Link to this callback

release(key, value, owner, partition)

View Source

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

Link to this callback

release_by_owner(key, owner, partition)

View Source

Specs

release_by_owner(key :: term(), owner :: term(), partition :: term()) ::
  :ok | {:error, :unknown_error}

Releases a value record via key, owner, partition set

Link to this callback

release_by_value(key, value, partition)

View Source

Specs

release_by_value(key :: term(), value :: term(), partition :: term()) ::
  :ok | {:error, :unknown_error}

Releases a value record via key, value, partition set