Class: ActiveJob::Locking::Adapters::SuoRedis

Inherits:
Base
  • Object
show all
Defined in:
lib/activejob/locking/adapters/suo-redis.rb

Instance Attribute Summary

Attributes inherited from Base

#key, #lock_manager, #lock_token, #options

Instance Method Summary collapse

Methods inherited from Base

#initialize, #refresh_lock!

Constructor Details

This class inherits a constructor from ActiveJob::Locking::Adapters::Base

Instance Method Details

#create_lock_managerObject



7
8
9
10
11
12
13
# File 'lib/activejob/locking/adapters/suo-redis.rb', line 7

def create_lock_manager
  mapped_options = {connection: {host: self.options.hosts.first},
                    stale_lock_expiration: self.options.lock_time,
                    acquisition_timeout: self.options.lock_acquire_time}

  Suo::Client::Redis.new(self.key, mapped_options)
end

#lockObject



15
16
17
# File 'lib/activejob/locking/adapters/suo-redis.rb', line 15

def lock
  self.lock_token = self.lock_manager.lock
end

#unlockObject



19
20
21
# File 'lib/activejob/locking/adapters/suo-redis.rb', line 19

def unlock
  self.lock_manager.unlock(self.lock_token)
end