Module: Dalli::Marshal

Defined in:
lib/dalli/options.rb

Overview

Auto-marshal all values in/out of memcached. Otherwise, Dalli will just use to_s on all values.

Dalli::Client.extend(Dalli::Marshal)

Instance Method Summary collapse

Instance Method Details

#append(key, value) ⇒ Object

Raises:



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

def append(key, value)
  raise Dalli::DalliError, "Marshalling and append do not work together"
end

#deserialize(value) ⇒ Object



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

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

#prepend(key, value) ⇒ Object

Raises:



27
28
29
# File 'lib/dalli/options.rb', line 27

def prepend(key, value)
  raise Dalli::DalliError, "Marshalling and prepend do not work together"
end

#serialize(value) ⇒ Object



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

def serialize(value)
  ::Marshal.dump(value)
end