Documentation
¶
Overview ¶
Package compress 提供数据压缩和解压缩功能
Index ¶
Constants ¶
View Source
const DefaultThreshold = 1024 // 1KB
压缩阈值:超过此大小的数据才进行压缩
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Compressor ¶
type Compressor interface {
Compress(data []byte) ([]byte, error)
Decompress(data []byte) ([]byte, error)
Type() uint8
}
Compressor 压缩器接口
type GzipCompressor ¶
type GzipCompressor struct {
// contains filtered or unexported fields
}
GzipCompressor gzip 压缩器
func NewGzipCompressor ¶
func NewGzipCompressor(threshold, level int) *GzipCompressor
NewGzipCompressor 创建 gzip 压缩器
func (*GzipCompressor) Compress ¶
func (c *GzipCompressor) Compress(data []byte) ([]byte, error)
Compress 压缩数据
func (*GzipCompressor) Decompress ¶
func (c *GzipCompressor) Decompress(data []byte) ([]byte, error)
Decompress 解压数据
func (*GzipCompressor) ShouldCompress ¶
func (c *GzipCompressor) ShouldCompress(size int) bool
ShouldCompress 判断是否需要压缩
Click to show internal directories.
Click to hide internal directories.