method
value
v3.2.13 -
Show latest stable
- Class:
ActiveSupport::Cache::Entry
value()public
Get the value stored in the cache.
# File activesupport/lib/active_support/cache.rb, line 575
def value
# If the original value was exactly false @value is still true because
# it is marshalled and eventually compressed. Both operations yield
# strings.
if @value
# In rails 3.1 and earlier values in entries did not marshaled without
# options[:compress] and if it's Numeric.
# But after commit a263f377978fc07515b42808ebc1f7894fafaa3a
# all values in entries are marshalled. And after that code below expects
# that all values in entries will be marshaled (and will be strings).
# So here we need a check for old ones.
begin
Marshal.load(compressed? ? Zlib::Inflate.inflate(@value) : @value)
rescue TypeError
compressed? ? Zlib::Inflate.inflate(@value) : @value
end
end
end Related methods
- Instance methods
- compressed?
- expired?
- expires_at
- expires_at=
- raw_value
- size
- value
- Class methods
- create
- new
- Private methods
-
should_compress?