{"repo":"leandromoreira/redlock-rb","free":true,"listed":false,"github":"https://github.com/leandromoreira/redlock-rb","clone":"git clone https://github.com/leandromoreira/redlock-rb.git","description":"Redlock is a redis-based distributed lock implementation in Ruby. More than 40 Millions of downloads.","language":"Ruby","stars":729,"topics":["redis","lock","distributed-locks","ruby","redlock"],"license":"BSD-2-Clause","category":"databases-storage","readme_excerpt":"Redlock - A ruby distributed lock using redis. Distributed locks are a very useful primitive in many environments where different processes require to operate with shared resources in a mutually exclusive way. There are a number of libraries and blog posts describing how to implement a DLM (Distributed Lock Manager) with Redis, but every library uses a different approach, and many use a simple approach with lower guarantees compared to what can be achieved with slightly more complex designs. This is an implementation of a proposed distributed lock algorithm with Redis. It started as a fork from antirez implementation. Compatibility It works with Redis server versions 6.0 or later. Redlock = 2.0 only works with RedisClient client instance. Installation Add this line to your application's Gemfile: And then execute: $ bundle Or install it yourself as: $ gem install redlock Documentation RubyDoc Usage example Acquiring a lock NOTE: All expiration durations are in milliseconds. There's also a block version that automatically unlocks the lock: There's also a bang version that only executes the block if the lock is successfully acquired, returning the block's value as a result, or raising an exception otherwise. Passing a block is mandatory. Extending a lock To extend the life of the lock: The above code will also acquire the lock if the previous lock has expired and the lock is currently free. Keep in mind that this means the lock could have been acquired and released by someone el","default_branch":null,"files":null,"tree":[],"storefront":"/r/leandromoreira","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/leandromoreira/redlock-rb/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}