123456789_123456789_123456789_123456789_123456789_

Module: ActiveSupport::Cache::SerializerWithFallback::Marshal70WithFallback

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
Defined in: activesupport/lib/active_support/cache/serializer_with_fallback.rb

Constant Summary

::ActiveSupport::Cache::SerializerWithFallback - Included

SERIALIZERS

Instance Method Summary

Instance Method Details

#_load(marked)

[ GitHub ]

  
# File 'activesupport/lib/active_support/cache/serializer_with_fallback.rb', line 88

def _load(marked)
  dumped = marked.byteslice(1..-1)
  dumped = Zlib::Inflate.inflate(dumped) if marked.start_with?(MARK_COMPRESSED)
  Cache::Entry.unpack(marshal_load(dumped))
end

#dump(entry)

[ GitHub ]

  
# File 'activesupport/lib/active_support/cache/serializer_with_fallback.rb', line 73

def dump(entry)
  MARK_UNCOMPRESSED + Marshal.dump(entry.pack)
end

#dump_compressed(entry, threshold)

[ GitHub ]

  
# File 'activesupport/lib/active_support/cache/serializer_with_fallback.rb', line 77

def dump_compressed(entry, threshold)
  dumped = Marshal.dump(entry.pack)

  if dumped.bytesize >= threshold
    compressed = Zlib::Deflate.deflate(dumped)
    return MARK_COMPRESSED + compressed if compressed.bytesize < dumped.bytesize
  end

  MARK_UNCOMPRESSED + dumped
end

#dumped?(dumped) ⇒ Boolean

[ GitHub ]

  
# File 'activesupport/lib/active_support/cache/serializer_with_fallback.rb', line 94

def dumped?(dumped)
  dumped.start_with?(MARK_UNCOMPRESSED, MARK_COMPRESSED)
end