Class: RedisLock::Semaphore
Instance Attribute Summary
Attributes inherited from Strategy
#args, #lock
Instance Method Summary
collapse
Methods inherited from Strategy
#initialize
Instance Method Details
14
15
16
|
# File 'lib/redis_lock/semaphore.rb', line 14
def after_perform
lock.unlock!
end
|
#call(&block) ⇒ Object
4
5
6
7
8
9
10
11
12
|
# File 'lib/redis_lock/semaphore.rb', line 4
def call(&block)
ttl = args[:ttl] || lock.config.default_ttl
set_opts = args[:set_opts] || {}
while lock.locked?
sleep (args[:wait] || 1)
end
lock.set(ttl, set_opts)
_perform(&block)
end
|