Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DeflatePool ¶
type DeflatePool struct {
// contains filtered or unexported fields
}
DeflatePool manages a pool of flate.Writer flate.NewWriter allocates a lot of memory, so if flate.Writer are needed frequently, it's more efficient to use a pool of them. The pool uses sync.Pool internally.
There is no pool for flate readers, because they implement io.ReadCloser and can't be recycled after closing.
var Deflate DeflatePool
func (*DeflatePool) GetWriter ¶
func (pool *DeflatePool) GetWriter(dst io.Writer) (writer *flate.Writer)
GetWriter returns flate.Writer from the pool, or creates a new one with flate.BestCompression if the pool is empty.
func (*DeflatePool) PutWriter ¶
func (pool *DeflatePool) PutWriter(writer *flate.Writer)
PutWriter returns a flate.Writer to the pool that can late be reused via GetWriter. Don't close the writer, Flush will be called before returning it to the pool.
type GzipPool ¶
type GzipPool struct {
// contains filtered or unexported fields
}
GzipPool manages a pool of gzip.Writer. The pool uses sync.Pool internally.
var Gzip GzipPool
func (*GzipPool) GetReader ¶
GetReader returns gzip.Reader from the pool, or creates a new one if the pool is empty.
func (*GzipPool) GetWriter ¶
GetWriter returns gzip.Writer from the pool, or creates a new one with gzip.BestCompression if the pool is empty.