Sha256: 9a0b74c9f7acf2376df882d3969b55a098ddef02d0b91cba86cf99c8ced6602e
Contents?: true
Size: 1.29 KB
Versions: 5
Compression:
Stored size: 1.29 KB
Contents
require 'thread' module Dalli # Auto-marshal all values in/out of memcached. # Otherwise, Dalli will just use to_s on all values. # # Dalli::Client.extend(Dalli::Marshal) # module Marshal def serialize(value) ::Marshal.dump(value) end def deserialize(value) begin ::Marshal.load(value) rescue TypeError raise Dalli::DalliError, "Invalid marshalled data in memcached, this happens if you switch the :marshal option and still have old data in memcached: #{value}" end end def append(key, value) raise Dalli::DalliError, "Marshalling and append do not work together" end def prepend(key, value) raise Dalli::DalliError, "Marshalling and prepend do not work together" end end # Make Dalli threadsafe by using a lock around all # public server methods. # # Dalli::Server.extend(Dalli::Threadsafe) # module Threadsafe def request(op, *args) lock.synchronize do super end end def alive? lock.synchronize do super end end def close lock.synchronize do super end end def lock! lock.mon_enter end def unlock! lock.mon_exit end private def lock @lock ||= Monitor.new end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
dalli-0.9.4 | lib/dalli/options.rb |
dalli-0.9.3 | lib/dalli/options.rb |
dalli-0.9.2 | lib/dalli/options.rb |
dalli-0.9.1 | lib/dalli/options.rb |
dalli-0.9.0 | lib/dalli/options.rb |