bufpool

package
v0.0.0-...-c39e8e5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2022 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultBytesSize = 32 * 1024

DefaultBytesSize is the default size of a bytes slice in a Bytes pool.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bytes

type Bytes struct {
	// contains filtered or unexported fields
}

Bytes is a bytes buffer pool that can be used in a http reverse proxy so that large transfers won't use up all memory really fast on a machine that does not have a lot of memory.

func NewBytes

func NewBytes(bufSize int) *Bytes

NewBytes creates a new bytes buffer pool, where each buffer is of bufSize. When bufSize is 0, 32k is used.

func (*Bytes) Get

func (p *Bytes) Get() []byte

Get gets a buffer from the pool.

func (*Bytes) Put

func (p *Bytes) Put(b []byte)

Put puts the bytes back to the pool.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL