Documentation
¶
Index ¶
Constants ¶
const ( // DefaultInitSize 是缓冲区的默认初始大小 (2KB) // DefaultInitSize is the default initial size of buffer (2KB) DefaultInitSize = 2048 // DefaultMaxCapacity 是缓冲区的默认最大容量 (1MB) // DefaultMaxCapacity is the default maximum capacity of buffer (1MB) DefaultMaxCapacity = 1 << 20 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BufferPool ¶
type BufferPool struct {
// contains filtered or unexported fields
}
BufferPool 是一个用于管理和复用 bytes.Buffer 的对象池 BufferPool is an object pool for managing and reusing bytes.Buffer objects
func NewBufferPool ¶
func NewBufferPool(initSize uint32) *BufferPool
NewBufferPool 创建一个新的 BufferPool 实例 NewBufferPool creates a new BufferPool instance
func (*BufferPool) Get ¶
func (p *BufferPool) Get() *bytes.Buffer
Get 从池中获取一个 bytes.Buffer 对象 Get retrieves a bytes.Buffer object from the pool
func (*BufferPool) GetMaxCapacity ¶ added in v0.1.11
func (p *BufferPool) GetMaxCapacity() uint32
GetMaxCapacity 返回当前池的最大容量限制 GetMaxCapacity returns the maximum capacity limit of the pool
func (*BufferPool) Put ¶
func (p *BufferPool) Put(buf *bytes.Buffer)
Put 将一个 bytes.Buffer 对象放回池中 Put returns a bytes.Buffer object back to the pool
type LogEventPool ¶
type LogEventPool struct {
// contains filtered or unexported fields
}
LogEventPool 结构体包含了一个用于管理日志事件对象池的 sync.Pool。 The LogEventPool struct contains a sync.Pool for managing log event object pooling.
func NewLogEventPool ¶
func NewLogEventPool() *LogEventPool
NewLogEventPool 函数返回一个新的 LogEventPool 实例。 The NewLogEventPool function returns a new LogEventPool instance.
func (*LogEventPool) Get ¶
func (p *LogEventPool) Get() *log.LogEvent
Get 方法从对象池中获取一个日志事件对象。 The Get method retrieves a log event object from the pool.
func (*LogEventPool) Put ¶
func (p *LogEventPool) Put(e *log.LogEvent)
Put 方法将日志事件对象放回对象池中。 The Put method returns a log event object to the pool.