Module: Dalli::Threadsafe

Defined in:
lib/dalli/options.rb

Overview

Make Dalli threadsafe by using a lock around all public server methods.

Dalli::Protocol::Binary.extend(Dalli::Threadsafe)

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(obj) ⇒ Object



12
13
14
# File 'lib/dalli/options.rb', line 12

def self.extended(obj)
  obj.init_threadsafe
end

Instance Method Details

#alive?Boolean

Returns:

  • (Boolean)


22
23
24
25
26
# File 'lib/dalli/options.rb', line 22

def alive?
  @lock.synchronize do
    super
  end
end

#closeObject



28
29
30
31
32
# File 'lib/dalli/options.rb', line 28

def close
  @lock.synchronize do
    super
  end
end

#init_threadsafeObject



60
61
62
# File 'lib/dalli/options.rb', line 60

def init_threadsafe
  @lock = Monitor.new
end

#lock!Object



52
53
54
# File 'lib/dalli/options.rb', line 52

def lock!
  @lock.mon_enter
end

#pipeline_abortObject



46
47
48
49
50
# File 'lib/dalli/options.rb', line 46

def pipeline_abort
  @lock.synchronize do
    super
  end
end

#pipeline_next_responsesObject



40
41
42
43
44
# File 'lib/dalli/options.rb', line 40

def pipeline_next_responses
  @lock.synchronize do
    super
  end
end

#pipeline_response_setupObject



34
35
36
37
38
# File 'lib/dalli/options.rb', line 34

def pipeline_response_setup
  @lock.synchronize do
    super
  end
end

#request(opcode, *args) ⇒ Object



16
17
18
19
20
# File 'lib/dalli/options.rb', line 16

def request(opcode, *args)
  @lock.synchronize do
    super
  end
end

#unlock!Object



56
57
58
# File 'lib/dalli/options.rb', line 56

def unlock!
  @lock.mon_exit
end