Class: Redislock::Lock
- Inherits:
-
Object
- Object
- Redislock::Lock
- Defined in:
- lib/redislock.rb
Instance Method Summary collapse
- #call ⇒ Object
- #extend(seconds) ⇒ Object
-
#initialize(key, &block) ⇒ Lock
constructor
A new instance of Lock.
- #relock(seconds) ⇒ Object
Constructor Details
#initialize(key, &block) ⇒ Lock
Returns a new instance of Lock.
50 51 52 |
# File 'lib/redislock.rb', line 50 def initialize(key, &block) @key, @block = key, block end |
Instance Method Details
#call ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'lib/redislock.rb', line 62 def call @block.call(self) return true ensure if Redislock.redis.del(@key) != 1 raise Error, "Lock was lost during run" end end |