cache

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2025 License: Apache-2.0 Imports: 1 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pool

type Pool[E any] struct {
	// contains filtered or unexported fields
}

Pool 是一个泛型化的 sync.Pool 封装,用于缓存和复用对象。 对象在释放回池时会被重置为零值。

func (*Pool[E]) Acquire

func (p *Pool[E]) Acquire() *E

Acquire 从池中获取一个对象。如果池为空则创建新对象。 返回的对象会被重置为零值(通过 Release 时的重置保证)。

func (*Pool[E]) Release

func (p *Pool[E]) Release(obj *E)

Release 将对象放回池中。如果对象为 nil 则直接返回。 放回前会将对象重置为零值以保证下次获取时的状态。

Jump to

Keyboard shortcuts

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