pool

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Factory

type Factory = func(context.Context) (interface{}, error)

type Option

type Option func(*pool)

func WithAge

func WithAge(maxAge int64) Option

WithAge defined element max age (millisecond)

func WithEvict

func WithEvict(cb func(interface{})) Option

WithEvict set the evict callback

func WithSize

func WithSize(maxSize int) Option

WithSize defined max size of Pool

type Pool

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

Pool is for GC, see New for detail

func New

func New(factory Factory, options ...Option) *Pool

func (Pool) Get

func (p Pool) Get() (interface{}, error)

func (Pool) GetContext

func (p Pool) GetContext(ctx context.Context) (interface{}, error)

func (Pool) Put

func (p Pool) Put(item interface{})

Jump to

Keyboard shortcuts

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