cache

package
v1.33.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache[K comparable, V any] struct {
	// contains filtered or unexported fields
}

Cache is a cache from K to V.

It uses double-locking to get values.

func (*Cache[K, V]) GetOrAdd

func (c *Cache[K, V]) GetOrAdd(key K, getUncached func() (V, error)) (V, error)

GetOrAdd gets the value for the key, or calls getUncached to get a new value, and then caches the value.

If getUncached calls another Cache, the order of GetOrAdd calls between caches must be preserved for lock ordering.

Jump to

Keyboard shortcuts

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