diff options
Diffstat (limited to 'activesupport/lib/active_support/cache/compressed_mem_cache_store.rb')
-rw-r--r-- | activesupport/lib/active_support/cache/compressed_mem_cache_store.rb | 15 |
1 files changed, 15 insertions, 0 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 new file mode 100644 index 0000000000..9470ac9f66 --- /dev/null +++ b/activesupport/lib/active_support/cache/compressed_mem_cache_store.rb @@ -0,0 +1,15 @@ +module ActiveSupport + module Cache + class CompressedMemCacheStore < MemCacheStore + def read(name, options = {}) + if value = super(name, options.merge(:raw => true)) + Marshal.load(ActiveSupport::Gzip.decompress(value)) + end + end + + def write(name, value, options = {}) + super(name, ActiveSupport::Gzip.compress(Marshal.dump(value)), options.merge(:raw => true)) + end + end + end +end |