X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=vendor%2Frails%2Factivesupport%2Flib%2Factive_support%2Fcache%2Fcompressed_mem_cache_store.rb;fp=vendor%2Frails%2Factivesupport%2Flib%2Factive_support%2Fcache%2Fcompressed_mem_cache_store.rb;h=d87eb17337141109b35e5f1a2f8f3e19b934a2e5;hb=d115f2e23823271635bad69229a42cd8ac68debe;hp=0000000000000000000000000000000000000000;hpb=37cb670bf3ddde90b214e591f100ed4446469484;p=depot.git diff --git a/vendor/rails/activesupport/lib/active_support/cache/compressed_mem_cache_store.rb b/vendor/rails/activesupport/lib/active_support/cache/compressed_mem_cache_store.rb new file mode 100644 index 0000000..d87eb17 --- /dev/null +++ b/vendor/rails/activesupport/lib/active_support/cache/compressed_mem_cache_store.rb @@ -0,0 +1,20 @@ +module ActiveSupport + module Cache + class CompressedMemCacheStore < MemCacheStore + def read(name, options = nil) + if value = super(name, (options || {}).merge(:raw => true)) + if raw?(options) + value + else + Marshal.load(ActiveSupport::Gzip.decompress(value)) + end + end + end + + def write(name, value, options = nil) + value = ActiveSupport::Gzip.compress(Marshal.dump(value)) unless raw?(options) + super(name, value, (options || {}).merge(:raw => true)) + end + end + end +end