locker

package
v0.0.0-...-a9153d3 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RateLimitTtl 请求记录在redis的存储时间
	RateLimitTtl = time.Minute
)

Variables

This section is empty.

Functions

func AddRateLimitRecord

func AddRateLimitRecord(ctx context.Context, key string, period time.Duration, maxTimes int64) (hitRateLimit bool, err error)

func Init

func Init(redisClient *redis.Client) error

func Lock

func Lock(ctx context.Context, lockKey string, options ...LockOption) (token string, err error)

func Unlock

func Unlock(ctx context.Context, lockKey, token string) error

Types

type LockOption

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

type LockOptions

type LockOptions []LockOption

type Locker

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

Jump to

Keyboard shortcuts

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