Module: Memcached::MarshalCodec

Defined in:
lib/memcached/marshal_codec.rb

Constant Summary collapse

FLAG =
Memcached::Client::FLAG_ENCODED

Class Method Summary collapse

Class Method Details

.decode(key, value, flags) ⇒ Object


9
10
11
12
13
14
15
# File 'lib/memcached/marshal_codec.rb', line 9

def self.decode(key, value, flags)
  if (flags & FLAG) != 0
    Marshal.load(value)
  else
    value
  end
end

.encode(key, value, flags) ⇒ Object


5
6
7
# File 'lib/memcached/marshal_codec.rb', line 5

def self.encode(key, value, flags)
  [ Marshal.dump(value), flags | FLAG ]
end