aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/cache/compressed_mem_cache_store.rb
blob: 3f1f9ad1795043bc893d38719aba25c61f55d3b2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
require "active_support/cache/mem_cache_store"

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