Class: ActiveSupport::Cache::Coder::LazyEntry

Inherits:
Entry show all
Defined in:
lib/active_support/cache/coder.rb

Instance Attribute Summary

Attributes inherited from Entry

#version

Instance Method Summary collapse

Methods inherited from Entry

#bytesize, #compressed, #compressed?, #dup_value!, #expired?, #expires_at, #expires_at=, #local?, #pack, unpack

Constructor Details

#initialize(serializer, compressor, payload, **options) ⇒ LazyEntry

Returns a new instance of LazyEntry.



99
100
101
102
103
104
# File 'lib/active_support/cache/coder.rb', line 99

def initialize(serializer, compressor, payload, **options)
  super(payload, **options)
  @serializer = serializer
  @compressor = compressor
  @resolved = false
end

Instance Method Details

#mismatched?(version) ⇒ Boolean

Returns:

  • (Boolean)


114
115
116
117
118
# File 'lib/active_support/cache/coder.rb', line 114

def mismatched?(version)
  super.tap { |mismatched| value if !mismatched }
rescue Cache::DeserializationError
  true
end

#valueObject



106
107
108
109
110
111
112
# File 'lib/active_support/cache/coder.rb', line 106

def value
  if !@resolved
    @value = @serializer.load(@compressor ? @compressor.inflate(@value) : @value)
    @resolved = true
  end
  @value
end