instance

package
v0.0.0-...-fcd50c7 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package instance 提供实例管理功能。

注意,此包不用于缓存,因为它没有缓存过期。 md5:9cde92d483190e72

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clear

func Clear()

Clear 删除所有存储的实例。 md5:19c1efdd76e32ce6

func Get

func Get(name string) interface{}

Get 根据给定的名称返回实例。 md5:a44f9ed4c07f4bd7

func GetOrSet

func GetOrSet(name string, instance interface{}) interface{}

GetOrSet 通过名称获取实例, 如果不存在,则将其设置到实例管理器中并返回该实例。 md5:6e30e1788811bdcf

func GetOrSetFunc

func GetOrSetFunc(name string, f func() interface{}) interface{}

GetOrSetFunc 通过名称获取实例, 如果不存在,它将使用回调函数 `f` 返回的值设置实例, 然后返回这个实例。 md5:3e2dff7c2a8267b6

func GetOrSetFuncLock

func GetOrSetFuncLock(name string, f func() interface{}) interface{}

GetOrSetFuncLock 通过名称获取实例, 如果该实例不存在,则使用回调函数 `f` 的返回值设置实例, 并随后返回这个实例。

GetOrSetFuncLock 与 GetOrSetFunc 函数的不同之处在于, 它在执行函数 `f` 时会对哈希映射加锁(mutex.Lock)。 md5:d7adba14d37045fa

func Set

func Set(name string, instance interface{})

Set 将给定名称的实例设置到实例管理器中。 md5:b2ea0ff086c307ba

func SetIfNotExist

func SetIfNotExist(name string, instance interface{}) bool

SetIfNotExist 如果`name`不存在,则将`instance`设置到地图中,然后返回true。 如果`name`已经存在,则忽略`instance`并返回false。 md5:0eb14110f7286ae3

Types

This section is empty.

Jump to

Keyboard shortcuts

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