singleflight

package
v0.0.0-...-15722f1 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Call

type Call struct {
	// contains filtered or unexported fields
}

type SingleFlight

type SingleFlight struct {
	// contains filtered or unexported fields
}

func (*SingleFlight) Do

func (sf *SingleFlight) Do(key string, fn func() (interface{}, error)) (interface{}, error)

使用 SingleFlight 对 Group 缓存未命中时的查询进行再封装,并发请求期间只有一个请求会以 goroutine 形式调用查询, 并发查询期间的所有其他请求均阻塞等待,当然我们也可以配置是否允许阻塞,给调用者更多选择

Jump to

Keyboard shortcuts

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