asyncLocal

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: MIT Imports: 2 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetContext added in v0.15.0

func GetContext[T any](key string) T

GetContext 获取Context

func GetOrSetContext added in v0.15.0

func GetOrSetContext[T any](key string, getValFunc func() T) T

GetOrSetContext 获取Context

func Release added in v0.15.0

func Release()

Release 释放

func Remove added in v0.15.0

func Remove[T any](key string)

Remove 移除缓存

func SetContext added in v0.15.0

func SetContext[T any](key string, getValFunc func() T)

SetContext 写入上下文

func SetContextIfNotExists added in v0.15.0

func SetContextIfNotExists[T any](key string, getValFunc func() T)

SetContextIfNotExists 写入上下文(如果不存在)

Types

type AsyncLocal

type AsyncLocal[T any] struct {
	// contains filtered or unexported fields
}

func New

func New[T any]() AsyncLocal[T]

New 创建一个AsyncLocal

func (AsyncLocal[T]) Get

func (receiver AsyncLocal[T]) Get() T

Get 获取值

func (AsyncLocal[T]) Remove

func (receiver AsyncLocal[T]) Remove()

Remove 移除对象

func (AsyncLocal[T]) Set

func (receiver AsyncLocal[T]) Set(t T)

Set 设置值

Jump to

Keyboard shortcuts

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