singleflight

package
v0.0.0-...-4b0e997 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package singleflight provides a mechanism to suppress duplicate Get() calls for a given key.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Group

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

func NewGroup

func NewGroup(concurrentCalls uint) *Group

func (*Group) Do

func (g *Group) Do(key string, f func() ([]byte, lifetime.Lifetime, error)) (bool, []byte, lifetime.Lifetime, error)

Do executes and returns the results of the given function, making sure that only one execution is in-flight for a given key at a time. If a call comes in for the same key, the duplicate caller waits for the original to complete and receives the same result. The first parameter indicates whether the call was deduplicated, and will be true for all but the first concurrent caller.

Jump to

Keyboard shortcuts

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