class RemoteLock::Adapters::Base
Public Class Methods
new(connection)
click to toggle source
# File lib/remote_lock/adapters/base.rb, line 6 def initialize(connection) @connection = connection end
valid?(adapter)
click to toggle source
# File lib/remote_lock/adapters/base.rb, line 22 def self.valid?(adapter) adapter.respond_to?(:store) && adapter.respond_to?(:has_key?) && adapter.respond_to?(:delete) end
Public Instance Methods
delete(key)
click to toggle source
# File lib/remote_lock/adapters/base.rb, line 18 def delete(key) raise NotImplementedError end
has_key?(key, options = {})
click to toggle source
# File lib/remote_lock/adapters/base.rb, line 14 def has_key?(key, options = {}) raise NotImplementedError end
store(key, options = {})
click to toggle source
# File lib/remote_lock/adapters/base.rb, line 10 def store(key, options = {}) raise NotImplementedError end
Private Instance Methods
thread_id()
click to toggle source
# File lib/remote_lock/adapters/base.rb, line 35 def thread_id Thread.current[:thread_uid] ||= SecureRandom.hex(4) end
uid()
click to toggle source
Globally unique ID for the current thread (or close enough)
# File lib/remote_lock/adapters/base.rb, line 31 def uid "#{Socket.gethostname}-#{Process.pid}-#{thread_id}" end