cache

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 2, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const ENV_GO_CACHE_DEFAULT_DURATION = "env_go_default_cache_duration"
View Source
const ENV_GO_CACHE_POOL_NAME = "env_go_default_cache_pool_name"

Variables

This section is empty.

Functions

func Delete

func Delete(key string) error

func Exist

func Exist(key string) bool

func Get

func Get(key string) interface{}

func Save

func Save(key string, value interface{})

保存数据,永远不过期

func SaveWithLifeSpan

func SaveWithLifeSpan(key string, value interface{}, lifeDuration time.Duration)

保存数据,指定时间后过期

Types

type ObjPool

type ObjPool struct {
	sync.Mutex
	Inuse     []interface{}
	Available []interface{}
	New       func() interface{}
	Reset     func(obj interface{})
}

func NewObjPool

func NewObjPool(new func() interface{}) *ObjPool

func (*ObjPool) Acquire

func (p *ObjPool) Acquire() interface{}

func (*ObjPool) Release

func (p *ObjPool) Release(object interface{})

type Pool

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

Pool is a pool of go routines.

func NewPool

func NewPool(parentCtx context.Context) *Pool

NewPool creates a Pool.

func (*Pool) GoCtx

func (p *Pool) GoCtx(goroutine routineCtx)

GoCtx starts a recoverable goroutine with a context.

func (*Pool) Stop

func (p *Pool) Stop()

Stop stops all started routines, waiting for their termination.

Jump to

Keyboard shortcuts

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