lib/active_support/cache.rb in activesupport-3.1.3 vs lib/active_support/cache.rb in activesupport-3.1.4.rc1
- old
+ new
@@ -553,11 +553,11 @@
def initialize(value, options = {})
@compressed = false
@expires_in = options[:expires_in]
@expires_in = @expires_in.to_f if @expires_in
@created_at = Time.now.to_f
- if value
+ unless value.nil?
if should_compress?(value, options)
@value = Zlib::Deflate.deflate(Marshal.dump(value))
@compressed = true
else
@value = value
@@ -572,10 +572,10 @@
@value
end
# Get the value stored in the cache.
def value
- if @value
+ unless @value.nil?
val = compressed? ? Marshal.load(Zlib::Inflate.inflate(@value)) : @value
unless val.frozen?
val.freeze rescue nil
end
val