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

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

Instance Method Summary collapse

Instance Method Details

#load(payload) ⇒ Object


849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
# File 'lib/active_support/cache.rb', line 849

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