Documentation ¶
Overview ¶
Package celllimiter 限制器 可以用于防止短时间内大量请求同时处理,比如缓存防击穿,防爬虫等
Index ¶
- func WithAutoRefreshInterval(autoRefreshInterval string) optparams.Option[Options]
- func WithDefaultCountPerPeriod(countPerPeriod int64) optparams.Option[Options]
- func WithDefaultPeriod(period int64) optparams.Option[Options]
- func WithKey(key string) optparams.Option[Options]
- func WithMaxSize(maxsize int64) optparams.Option[Options]
- func WithMaxTTL(maxTTL time.Duration) optparams.Option[Options]
- func WithNamespace(ns ...string) optparams.Option[Options]
- func WithSpecifiedKey(key string) optparams.Option[Options]
- func WithTaskCron(taskCron *cron.Cron) optparams.Option[Options]
- func WithWarningSize(warningSize int64) optparams.Option[Options]
- type Limiter
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithAutoRefreshInterval ¶
WithAutoRefreshInterval 设置自动刷新过期时间的设置
func WithDefaultCountPerPeriod ¶
WithDefaultCountPerPeriod 设置时间间隔内的token消减数
func WithDefaultPeriod ¶
WithDefaultPeriod 设置token消减间隔时长,单位s
func WithMaxSize ¶
WithMaxSize 设置最大水位,必须大于0
func WithMaxTTL ¶
WithMaxTTL 设置token消减间隔时长,单位s
func WithNamespace ¶
WithNamespace 中间件通用设置,指定锁的命名空间
func WithSpecifiedKey ¶
WithSpecifiedKey 中间件通用设置,指定使用的键,注意设置key后namespace将失效
func WithTaskCron ¶
WithTaskCron 设置定时器
Types ¶
type Limiter ¶
type Limiter struct { *cellhelper.RedisCell *limiterhelper.LimiterABC // contains filtered or unexported fields }
Limiter 分布式限制器
type Options ¶
type Options struct { LimiterOpts []optparams.Option[limiterhelper.Options] CellOpts []optparams.Option[cellhelper.Options] }
Click to show internal directories.
Click to hide internal directories.