Store that compresses cached data using GZip. Usually wraps other stores and good for caching of large pages.
# File lib/merb-cache/stores/strategy/gzip_store.rb, line 47 47: def compress(data) 48: return if data.nil? 49: 50: output = StringIO.new 51: gz = Zlib::GzipWriter.new(output) 52: gz.write(Marshal.dump(data)) 53: gz.close 54: output.string 55: end
# File lib/merb-cache/stores/strategy/gzip_store.rb, line 57 57: def decompress(data) 58: return if data.nil? 59: 60: Marshal.load(Zlib::GzipReader.new(StringIO.new(data)).read) 61: end
# File lib/merb-cache/stores/strategy/gzip_store.rb, line 39 39: def delete(key, parameters = {}) 40: @stores.map {|c| c.delete(key, parameters)}.any? 41: end
# File lib/merb-cache/stores/strategy/gzip_store.rb, line 43 43: def delete_all! 44: @stores.map {|c| c.delete_all! }.all? 45: end
# File lib/merb-cache/stores/strategy/gzip_store.rb, line 35 35: def exists?(key, parameters = {}) 36: @stores.capture_first {|c| c.exists?(key, parameters)} 37: end
# File lib/merb-cache/stores/strategy/gzip_store.rb, line 30 30: def fetch(key, parameters = {}, conditions = {}, &blk) 31: wrapper_blk = lambda { compress(blk.call) } 32: read(key, parameters) || decompress(@stores.capture_first {|s| s.fetch(key, parameters, conditions, &wrapper_blk)}) 33: end
# File lib/merb-cache/stores/strategy/gzip_store.rb, line 14 14: def read(key, parameters = {}) 15: decompress(@stores.capture_first {|c| c.read(key, parameters)}) 16: end
# File lib/merb-cache/stores/strategy/gzip_store.rb, line 10 10: def writable?(key, parameters = {}, conditions = {}) 11: @stores.any? {|c| c.writable?(key, parameters, conditions)} 12: end
# File lib/merb-cache/stores/strategy/gzip_store.rb, line 18 18: def write(key, data = nil, parameters = {}, conditions = {}) 19: if writable?(key, parameters, conditions) 20: @stores.capture_first {|c| c.write(key, compress(data), parameters, conditions)} 21: end 22: end
# File lib/merb-cache/stores/strategy/gzip_store.rb, line 24 24: def write_all(key, data = nil, parameters = {}, conditions = {}) 25: if writable?(key, parameters, conditions) 26: @stores.map {|c| c.write_all(key, compress(data), parameters, conditions)}.all? 27: end 28: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.