Module: ActiveSupport::Cache::Coders::Loader

Extended by:
Loader
Included in:
Loader, Rails61Coder, Rails70Coder
Defined in:
activesupport/lib/active_support/cache.rb

Instance Method Summary collapse

Instance Method Details

#load(payload) ⇒ Object



952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
# File 'activesupport/lib/active_support/cache.rb', line 952

def load(payload)
  if !payload.is_a?(String)
    ActiveSupport::Cache::Store.logger&.warn %{Payload wasn't a string, was #{payload.class.name} - couldn't unmarshal, so returning nil."}

    return nil
  elsif payload.start_with?(MARK_70_UNCOMPRESSED)
    members = Marshal.load(payload.byteslice(1..-1))
  elsif payload.start_with?(MARK_70_COMPRESSED)
    members = Marshal.load(Zlib::Inflate.inflate(payload.byteslice(1..-1)))
  elsif payload.start_with?(MARK_61)
    return Marshal.load(payload)
  else
    ActiveSupport::Cache::Store.logger&.warn %{Invalid cache prefix: #{payload.byteslice(0).inspect}, expected "\\x00" or "\\x01"}

    return nil
  end
  Entry.unpack(members)
end