redis_mutex v0.3.0 RedisMutex View Source
An Elixir library for using Redis locks
Setup
- Add
redis_mutex
to your list of dependencies inmix.exs
:
def deps do
[{:redis_mutex, "~> 0.1.0"}]
end
- Ensure
redis_mutex
is started before your application:
def application do
[applications: [:redis_mutex]]
end
- Set the
redis_url
in yourconfig.exs
config :redis_mutex, redis_url: {:system, "REDIS_URL"}
- Call
use RedisMutex
in the module you want to use the lock.
defmodule PossumLodge do
def get_oath do
"Quando omni flunkus moritati"
end
end
With a Redis lock:
defmodule PossumLodge do
use RedisMutex
def get_oath do
with_lock("my_key") do
"Quando omni flunkus moritati"
end
end
end
Link to this section Summary
Functions
The start function will get the redis_url from the config and connect to the Redis instance.
Link to this section Functions
Link to this function
children(arg1) View Source
Link to this function
start(type, args) View Source
The start function will get the redis_url from the config and connect to the Redis instance.