Versions in this module Expand all Collapse all v2 v2.0.0 May 31, 2022 Changes in this version + var Defaultopt = Options + var ErrLimiterMaxSizeMustLargerThanWaringSize = errors.New("limiter的最大容量必须大于警戒容量") + type Hook func(res, maxsize int64) error + type Limiter struct + Client redis.UniversalClient + Key string + func New(client redis.UniversalClient, key string, opts ...Option) (*Limiter, error) + func (c *Limiter) Capacity() int64 + func (c *Limiter) Flood(ctx context.Context, value int64) (bool, error) + func (c *Limiter) IsFull(ctx context.Context) (bool, error) + func (c *Limiter) Reset(ctx context.Context) error + func (c *Limiter) WaterLevel(ctx context.Context) (int64, error) + type Option interface + Apply func(*Options) + func WithAsyncHooks() Option + func WithFullHook(hook Hook) Option + func WithMaxSize(maxsize int64) Option + func WithMaxTTL(maxTTL time.Duration) Option + func WithWarningHook(hook Hook) Option + func WithWarningSize(warningSize int64) Option + type Options struct + AsyncHooks bool + FullHooks []Hook + MaxSize int64 + MaxTTL time.Duration + WarningHooks []Hook + WarningSize int64 Other modules containing this package github.com/Golang-Tools/redishelper