aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support
diff options
context:
space:
mode:
authorBrian Durand <brian@embellishedvisions.com>2011-07-29 17:27:45 -0500
committerXavier Noria <fxn@hashref.com>2011-08-13 16:22:24 -0700
commit48fce08bb3606b989a20f5e60f9243e627099339 (patch)
tree32206a809fb04ebb83bed3c6ac8c72e49efcea8c /activesupport/lib/active_support
parentf85b9662699d7b77fd9ad4e1303565fdaaed0379 (diff)
downloadrails-48fce08bb3606b989a20f5e60f9243e627099339.tar.gz
rails-48fce08bb3606b989a20f5e60f9243e627099339.tar.bz2
rails-48fce08bb3606b989a20f5e60f9243e627099339.zip
Change ActiveSupport::Cache behavior to always return duplicate objects instead of 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