rdb

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Distributed

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

Distributed is redis limiter.

Example

nolint: testableexamples

client := redis.NewClient(&redis.Options{
	Addr:     "localhost:6379",
	Password: "",
	DB:       0,
})
start := time.Now()
limiter := rdb.NewDistributed(client, "key", 1000, time.Second)
ctx := context.Background()

_ = limiter.Wait(ctx)
_ = limiter.Wait(ctx)
_ = limiter.Wait(ctx)

fmt.Println(time.Since(start))
Output:

func NewDistributed

func NewDistributed(client redis.Cmdable, key string, qps int, timeOut time.Duration) *Distributed

NewDistributed returns redis limiter.

func (*Distributed) Wait

func (p *Distributed) Wait(ctx context.Context) error

Wait is concurrent flow control.

Directories

Path Synopsis
Package redis is a generated GoMock package.
Package redis is a generated GoMock package.

Jump to

Keyboard shortcuts

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