Nebulex.Adapter.Transaction behaviour (Nebulex v3.0.0)

Copy Markdown View Source

Specifies the adapter Transaction API.

Summary

Callbacks

Returns {:ok, true} if the current process is inside a transaction; otherwise, {:ok, false} is returned.

Runs the given function inside a transaction.

Callbacks

in_transaction?(adapter_meta, opts)

Returns {:ok, true} if the current process is inside a transaction; otherwise, {:ok, false} is returned.

If there's an error with executing the command, {:error, reason} is returned, where reason is the cause of the error.

See Nebulex.Cache.in_transaction?/1.

transaction(adapter_meta, fun, opts)

Runs the given function inside a transaction.

If an Elixir exception occurs, the exception will bubble up from the transaction function. If the cache aborts the transaction, it returns {:error, reason}.

A successful transaction returns the value returned by the function wrapped in a tuple as {:ok, value}.

See Nebulex.Cache.transaction/2.