Documentation ¶
Overview ¶
Package instance provides instances management.
Note that this package is not used for cache, as it has no cache expiration.
Index ¶
- func Clear()
- func Get(name string) interface{}
- func GetOrSet(name string, instance interface{}) interface{}
- func GetOrSetFunc(name string, f func() interface{}) interface{}
- func GetOrSetFuncLock(name string, f func() interface{}) interface{}
- func Set(name string, instance interface{})
- func SetIfNotExist(name string, instance interface{}) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetOrSet ¶
func GetOrSet(name string, instance interface{}) interface{}
GetOrSet returns the instance by name, or set instance to the instance manager if it does not exist and returns this instance.
func GetOrSetFunc ¶
func GetOrSetFunc(name string, f func() interface{}) interface{}
GetOrSetFunc returns the instance by name, or sets instance with returned value of callback function `f` if it does not exist and then returns this instance.
func GetOrSetFuncLock ¶
func GetOrSetFuncLock(name string, f func() interface{}) interface{}
GetOrSetFuncLock returns the instance by name, or sets instance with returned value of callback function `f` if it does not exist and then returns this instance.
GetOrSetFuncLock differs with GetOrSetFunc function is that it executes function `f` with mutex.Lock of the hash map.
Types ¶
This section is empty.