Module: Redis::Lockers
- Defined in:
- lib/redis/lockers.rb,
lib/redis/lockers/lock.rb,
lib/redis/lockers/version.rb
Overview
Distributed locks with Redis.
Defined Under Namespace
Classes: Lock
Constant Summary collapse
- VERSION =
Gem version.
"1.0.0"
Class Method Summary collapse
-
.acquire(redis, *args, **kwargs) { ... } ⇒ Object
Creates new lock and yields control if it was successfully acquired.
Class Method Details
.acquire(redis, *args, **kwargs) { ... } ⇒ Object
Creates new lock and yields control if it was successfully acquired. Ensures lock is released after execution of the block.
22 23 24 25 26 27 |
# File 'lib/redis/lockers.rb', line 22 def self.acquire(redis, *args, **kwargs) lock = Lock.new(*args, **kwargs) yield if lock.acquire(redis) ensure lock&.release(redis) end |