Module: Dalli::Threadsafe

Defined in:
lib/dalli/options.rb

Overview

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

Dalli::Server.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

#multi_response_abortObject



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

def multi_response_abort
  @lock.synchronize do
    super
  end
end

#multi_response_nonblockObject



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

def multi_response_nonblock
  @lock.synchronize do
    super
  end
end

#multi_response_startObject



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

def multi_response_start
  @lock.synchronize do
    super
  end
end

#request(op, *args) ⇒ Object



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

def request(op, *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