aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2011-07-29 16:20:21 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2011-07-29 16:20:21 -0700
commitae1e70cf803390edadf5263a1550c76dbcb3ca46 (patch)
tree037628575cf3dad21ca76826668d5c544388141a /activesupport/lib/active_support
parentea7f50863d3a1e58a28921b15da3927ad7d18f4a (diff)
parenta263f377978fc07515b42808ebc1f7894fafaa3a (diff)
downloadrails-ae1e70cf803390edadf5263a1550c76dbcb3ca46.tar.gz
rails-ae1e70cf803390edadf5263a1550c76dbcb3ca46.tar.bz2
rails-ae1e70cf803390edadf5263a1550c76dbcb3ca46.zip
Merge pull request #2353 from bdurand/no_freeze_cache_entries
Change ActiveSupport::Cache behavior to not return frozen objects
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r--activesupport/lib/active_support/cache.rb23
1 files changed, 8 insertions, 15 deletions
diff --git a/activesupport/lib/active_support/cache.rb b/activesupport/lib/active_support/cache.rb
index ac88c82709..2d2264e58a 100644
--- a/activesupport/lib/active_support/cache.rb
+++ b/activesupport/lib/active_support/cache.rb
@@ -557,15 +557,14 @@ module ActiveSupport
@expires_in = options[:expires_in]
@expires_in = @expires_in.to_f if @expires_in
@created_at = Time.now.to_f
- if defined?(value)
+ if value.nil?
+ @value = nil
+ else
+ @value = Marshal.dump(value)
if should_compress?(value, options)
- @value = Zlib::Deflate.deflate(Marshal.dump(value))
+ @value = Zlib::Deflate.deflate(@value)
@compressed = true
- else
- @value = value
end
- else
- @value = nil
end
end
@@ -576,12 +575,8 @@ module ActiveSupport
# Get the value stored in the cache.
def value
- if defined?(@value)
- val = compressed? ? Marshal.load(Zlib::Inflate.inflate(@value)) : @value
- unless val.frozen?
- val.freeze rescue nil
- end
- val
+ if @value
+ Marshal.load(compressed? ? Zlib::Inflate.inflate(@value) : @value)
end
end
@@ -614,10 +609,8 @@ module ActiveSupport
def size
if @value.nil?
0
- elsif @value.respond_to?(:bytesize)
- @value.bytesize
else
- Marshal.dump(@value).bytesize
+ @value.bytesize
end
end