singleflight

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2021 License: MIT Imports: 2 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
}

singleflight Call, only call fn once it's a wrapper of sync.Once to store return values

func NewCall

func NewCall(fn func() (interface{}, error)) *Call

func (*Call) Do

func (c *Call) Do() (interface{}, error)

type Group

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

a group of Call, use key to identify

func (*Group) Do

func (g *Group) Do(key string, fn func() (interface{}, error), forgetAfter time.Duration) (interface{}, error)

about forgetAfter: - timer start before fn be called - only make sense if this call not hit cache, so you can't reset forget time - non-positive value means never forget

func (*Group) Forget

func (g *Group) Forget(key string)

Jump to

Keyboard shortcuts

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