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


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

def self.extended(obj)
  obj.init_threadsafe
end

Instance Method Details

#alive?Boolean

Returns:

  • (Boolean)

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

def alive?
  @lock.synchronize do
    super
  end
end

#closeObject


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

def close
  @lock.synchronize do
    super
  end
end

#init_threadsafeObject


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

def init_threadsafe
  @lock = Monitor.new
end

#lock!Object


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

def lock!
  @lock.mon_enter
end

#multi_response_abortObject


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

def multi_response_abort
  @lock.synchronize do
    super
  end
end

#multi_response_nonblockObject


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

def multi_response_nonblock
  @lock.synchronize do
    super
  end
end

#multi_response_startObject


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

def multi_response_start
  @lock.synchronize do
    super
  end
end

#request(op, *args) ⇒ Object


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

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

#unlock!Object


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

def unlock!
  @lock.mon_exit
end