Class: Redis::Marshal

Inherits:
Object
  • Object
show all
Defined in:
lib/redis/marshal.rb

Class Method Summary collapse

Class Method Details

.dump(value) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'lib/redis/marshal.rb', line 3

def self.dump(value)
  case value
  when String
    value
  when Fixnum
    value
  else
    ::Marshal.dump(value) rescue nil
  end
end

.load(value) ⇒ Object



14
15
16
17
18
# File 'lib/redis/marshal.rb', line 14

def self.load(value)
  return nil if value.nil?
  return value unless value.start_with?("\004")
  ::Marshal.load(value) rescue value
end