Method: ActiveSupport::Cache::Coder#load

Defined in:
lib/active_support/cache/coder.rb

#load(dumped) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/active_support/cache/coder.rb', line 48

def load(dumped)
  return @serializer.load(dumped) if !signature?(dumped)

  type = dumped.unpack1(PACKED_TYPE_TEMPLATE)
  expires_at = dumped.unpack1(PACKED_EXPIRES_AT_TEMPLATE)
  version_length = dumped.unpack1(PACKED_VERSION_LENGTH_TEMPLATE)

  expires_at = nil if expires_at < 0
  version = load_version(dumped.byteslice(PACKED_VERSION_INDEX, version_length)) if version_length >= 0
  payload = dumped.byteslice((PACKED_VERSION_INDEX + [version_length, 0].max)..)

  compressor = @compressor if type & COMPRESSED_FLAG > 0
  serializer = STRING_DESERIALIZERS[type & ~COMPRESSED_FLAG] || @serializer

  LazyEntry.new(serializer, compressor, payload, version: version, expires_at: expires_at)
end