diff options
author | Ryan Bigg <radarlistener@gmail.com> | 2008-10-22 21:46:49 +1030 |
---|---|---|
committer | Ryan Bigg <radarlistener@gmail.com> | 2008-10-22 21:46:49 +1030 |
commit | 4a53eb8a79e3e0535ba19e6da38370a542ce4961 (patch) | |
tree | 965418cb69895e44879c7b1fa428e808b91aa66a /activesupport/lib/active_support/cache | |
parent | a325010d6c9b2c69cab5da046e1106aad491b73f (diff) | |
parent | 303919c62660c68ca450a53ec5ef29ec2c615b7a (diff) | |
download | rails-4a53eb8a79e3e0535ba19e6da38370a542ce4961.tar.gz rails-4a53eb8a79e3e0535ba19e6da38370a542ce4961.tar.bz2 rails-4a53eb8a79e3e0535ba19e6da38370a542ce4961.zip |
Merge branch 'master' of git@github.com:lifo/docrails
Diffstat (limited to 'activesupport/lib/active_support/cache')
3 files changed, 11 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/cache/compressed_mem_cache_store.rb b/activesupport/lib/active_support/cache/compressed_mem_cache_store.rb index 0bff6cf9ad..d87eb17337 100644 --- a/activesupport/lib/active_support/cache/compressed_mem_cache_store.rb +++ b/activesupport/lib/active_support/cache/compressed_mem_cache_store.rb @@ -3,12 +3,17 @@ module ActiveSupport class CompressedMemCacheStore < MemCacheStore def read(name, options = nil) if value = super(name, (options || {}).merge(:raw => true)) - Marshal.load(ActiveSupport::Gzip.decompress(value)) + if raw?(options) + value + else + Marshal.load(ActiveSupport::Gzip.decompress(value)) + end end end def write(name, value, options = nil) - super(name, ActiveSupport::Gzip.compress(Marshal.dump(value)), (options || {}).merge(:raw => true)) + value = ActiveSupport::Gzip.compress(Marshal.dump(value)) unless raw?(options) + super(name, value, (options || {}).merge(:raw => true)) end end end diff --git a/activesupport/lib/active_support/cache/file_store.rb b/activesupport/lib/active_support/cache/file_store.rb index ef533633b2..ffe0baba99 100644 --- a/activesupport/lib/active_support/cache/file_store.rb +++ b/activesupport/lib/active_support/cache/file_store.rb @@ -16,6 +16,7 @@ module ActiveSupport super ensure_cache_path(File.dirname(real_file_path(name))) File.atomic_write(real_file_path(name), cache_path) { |f| Marshal.dump(value, f) } + value rescue => e logger.error "Couldn't create cache directory: #{name} (#{e.message})" if logger end diff --git a/activesupport/lib/active_support/cache/mem_cache_store.rb b/activesupport/lib/active_support/cache/mem_cache_store.rb index 58958dccef..5531c30b7f 100644 --- a/activesupport/lib/active_support/cache/mem_cache_store.rb +++ b/activesupport/lib/active_support/cache/mem_cache_store.rb @@ -34,6 +34,9 @@ module ActiveSupport def write(key, value, options = nil) super method = options && options[:unless_exist] ? :add : :set + # memcache-client will break the connection if you send it an integer + # in raw mode, so we convert it to a string to be sure it continues working. + value = value.to_s if raw?(options) response = @data.send(method, key, value, expires_in(options), raw?(options)) response == Response::STORED rescue MemCache::MemCacheError => e |