Class: ActiveSupport::Cache::CompressedMemCacheStore

Inherits:
MemCacheStore show all
Defined in:
lib/active_support/cache/compressed_mem_cache_store.rb

Instance Attribute Summary

Attributes inherited from Store

#logger_off, #silence

Instance Method Summary collapse

Methods inherited from MemCacheStore

build_mem_cache, #clear, #decrement, #delete, #delete_matched, #exist?, #increment, #initialize, #read_multi, #stats

Methods inherited from Store

#decrement, #delete, #delete_matched, #exist?, #fetch, #increment, #mute, #silence!

Constructor Details

This class inherits a constructor from ActiveSupport::Cache::MemCacheStore

Instance Method Details

#read(name, options = nil) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/active_support/cache/compressed_mem_cache_store.rb', line 4

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

#write(name, value, options = nil) ⇒ Object



14
15
16
17
# File 'lib/active_support/cache/compressed_mem_cache_store.rb', line 14

def write(name, value, options = nil)
  value = ActiveSupport::Gzip.compress(Marshal.dump(value)) unless raw?(options)
  super(name, value, (options || {}).merge(:raw => true))
end