limiter

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Limiter

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

func NewCache

func NewCache(options *redis.Options) (*Limiter, error)

创建Redis连接

func (*Limiter) CountLimit

func (l *Limiter) CountLimit(key string, count uint, ttl int64) bool

不保证流程原子性,存在并发竞争问题

func (*Limiter) SyncCountLimit

func (l *Limiter) SyncCountLimit(key string, count uint, ttl int64) bool

Lua脚本保证流程原子性,并发安全

func (*Limiter) SyncWindowLimit

func (l *Limiter) SyncWindowLimit(key string, count uint, windowTime int64) bool

Lua脚本保证流程原子性,并发安全

func (*Limiter) WindowLimit

func (l *Limiter) WindowLimit(key string, count uint, windowTime int64) bool

不保证流程原子性,存在并发竞争问题

Jump to

Keyboard shortcuts

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