Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetOrUpdate ¶
func GetOrUpdate( cache *FactsCache, entry string, udpateFunc UpdateCacheFunc, updateFuncArgs ...interface{}, ) (interface{}, error)
GetOrUpdate Runs FactsCache GetOrUpdate with a provided cache If the cache is nil, it runs the function, otherwise it returns from cache
Types ¶
type FactsCache ¶
type FactsCache struct {
// contains filtered or unexported fields
}
func NewFactsCache ¶
func NewFactsCache() *FactsCache
func (*FactsCache) Entries ¶
func (c *FactsCache) Entries() []string
Entries returns the cached entries list
func (*FactsCache) GetOrUpdate ¶
func (c *FactsCache) GetOrUpdate( entry string, udpateFunc UpdateCacheFunc, updateFuncArgs ...interface{}, ) (interface{}, error)
GetOrUpdate returns the cached result providing an entry name or runs the updateFunc to generate the entry. It locks its usage for each used key, returning the same value of the first execution in the additional usages. If other function with a different key is asked, it runs in parallel without blocking.
type UpdateCacheFunc ¶
type UpdateCacheFunc func(args ...interface{}) (interface{}, error)
Click to show internal directories.
Click to hide internal directories.