RedMutex v0.1.0 RedMutex behaviour View Source

defmodule MyMutex do
  use RedMutex, otp_app: :my_app
end

config :my_app, MyMutex,
  redis_url: "redis://redix.example.com:6380",
  key: "something"

{:ok, mutex} = MyMutex.lock(12)

true = MyMutex.locked?

:ok = MyMutex.unlock(mutex)

import MyMutex, only: [synchronize: 1]

synchronize do
  // work
end

Link to this section Summary

Link to this section Types

Link to this type

callback() View Source
callback() ::
  (... -> any())
  | {module :: atom(), function_name :: atom(), args :: [any()]}

Link to this section Callbacks

Link to this callback

exists_lock() View Source
exists_lock() :: {:ok, boolean()} | {:error, reason()}

Link to this callback

lock() View Source
lock() :: {:ok, mutex()} | {:error, reason()}

Link to this callback

synchronize(callback) View Source
synchronize(callback()) :: any()

Link to this callback

unlock(mutex) View Source
unlock(mutex()) :: :ok | {:error, reason()}