Skip to content

Dounx/distributed_mutex

Repository files navigation

DistributedMutex

Simple distributed locks with Redis.

Installation (Not be uploaded to rubygems yet)

gem install distributed_mutex

Or you can install via Bundler if you are using Rails. Add this line to your application's Gemfile:

gem 'distributed_mutex'

And then execute:

bundle

Basic Usage

redis = Redis.new
key = "foo:bar"
mutex = DistributedMutex.new(redis, key)

# Not wait for a lock 
mutex.synchronize { 1 + 1 == 2 }

# Wait for a lock
mutex.synchronize(wait: true) { 1 + 1 == 2 }

# Extend a existed lock
mutex.extend_lock(100)

Build

git clone https://github.com/Dounx/distributed_mutex
cd distributed_mutex
gem build distributed_mutex.gemspec
gem install --local distributed_mutex-*.gem

Rake

List of available tasks.

rake --tasks

License

DistributedMutex is an open-sourced software licensed under the MIT license.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages