Sha256: 3a626219361acd70605e17a4ffeedee4b759d13cb552cd7de5d6b21624daad16

Contents?: true

Size: 494 Bytes

Versions: 13

Compression:

Stored size: 494 Bytes

Contents

require 'resque/scheduler/lock/base'

module Resque
  class Scheduler
    module Lock
      class Basic < Base
        def acquire!
          if Resque.redis.setnx(key, value)
            extend_lock!
            true
          end
        end

        def locked?
          if Resque.redis.get(key) == value
            extend_lock!

            if Resque.redis.get(key) == value
              return true
            end
          end

          false
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
resque-scheduler-2.5.5 lib/resque/scheduler/lock/basic.rb
resque-scheduler-2.5.4 lib/resque/scheduler/lock/basic.rb
resque-scheduler-2.5.3 lib/resque/scheduler/lock/basic.rb
resque-scheduler-2.5.2 lib/resque/scheduler/lock/basic.rb
resque-scheduler-2.5.1 lib/resque/scheduler/lock/basic.rb
resque-scheduler-2.5.0 lib/resque/scheduler/lock/basic.rb
resque-scheduler-2.4.0 lib/resque/scheduler/lock/basic.rb
resque-scheduler-2.3.1 lib/resque/scheduler/lock/basic.rb
resque-scheduler-2.3.0 lib/resque/scheduler/lock/basic.rb
resque-scheduler-2.2.0 lib/resque/scheduler/lock/basic.rb
resque-scheduler-2.1.1 lib/resque/scheduler/lock/basic.rb
resque-scheduler-2.1.0 lib/resque/scheduler/lock/basic.rb
resque-scheduler-2.0.1 lib/resque/scheduler/lock/basic.rb