Module: Zlib::GzipCompression
- Defined in:
- lib/zlib/gzip_compression.rb
Overview
Compress data over the wire to Redis with GZip. This code was mostly stolen from Dalli::GzipCompressor.
github.com/petergoldstein/dalli/blob/master/lib/dalli/compressor.rb
Class Method Summary collapse
-
.deflate(data) ⇒ String
Compress the given data with GZip.
-
.inflate(data) ⇒ String
Decompress the given data with GZip.
Class Method Details
.deflate(data) ⇒ String
Compress the given data with GZip.
11 12 13 14 15 16 17 18 19 |
# File 'lib/zlib/gzip_compression.rb', line 11 def self.deflate(data) io = StringIO.new(String.new(""), "w") gz = Zlib::GzipWriter.new(io) gz.write(data) gz.close io.string end |
.inflate(data) ⇒ String
Decompress the given data with GZip.
25 26 27 28 29 30 |
# File 'lib/zlib/gzip_compression.rb', line 25 def self.inflate(data) io = StringIO.new(data, "rb") gz = Zlib::GzipReader.new(io) gz.read end |