Ruby 直接对内存中的字符串进行压缩和解压

require 'zlib'

deflated = Zlib::Deflate.deflate("this is a test.")
puts deflated
puts Zlib::Inflate.inflate(deflated)

编程技巧