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)

Instance Method Summary collapse

Instance Method Details

#alive?Boolean

Returns:

  • (Boolean)


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

def alive?
  lock.synchronize do
    super
  end
end

#closeObject



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

def close
  lock.synchronize do
    super
  end
end

#lock!Object



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

def lock!
  lock.mon_enter
end

#request(op, *args) ⇒ Object



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

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

#unlock!Object



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

def unlock!
  lock.mon_exit
end