Class: Resque::Scheduler::Lock::Resilient

Inherits:
Base
  • Object
show all
Defined in:
lib/resque/scheduler/lock/resilient.rb

Overview

rubocop:disable TrailingComma

Instance Attribute Summary

Attributes inherited from Base

#key, #timeout

Instance Method Summary collapse

Methods inherited from Base

#initialize, #release!, #value

Constructor Details

This class inherits a constructor from Resque::Scheduler::Lock::Base

Instance Method Details

#acquire!Object



7
8
9
10
11
12
13
# File 'lib/resque/scheduler/lock/resilient.rb', line 7

def acquire!
  Resque.redis.evalsha(
    acquire_sha,
    :keys => [key],
    :argv => [value]
  ).to_i == 1
end

#locked?Boolean

Returns:

  • (Boolean)


15
16
17
18
19
20
21
# File 'lib/resque/scheduler/lock/resilient.rb', line 15

def locked?
  Resque.redis.evalsha(
    locked_sha,
    :keys => [key],
    :argv => [value]
  ).to_i == 1
end

#timeout=(seconds) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/resque/scheduler/lock/resilient.rb', line 23

def timeout=(seconds)
  if locked?
    @timeout = seconds
    @locked_sha = nil
    @acquire_sha = nil
  end
  @timeout
end