counter

package
v1.1.62 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetOption

func SetOption(o *Option)

Types

type Counter

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

func GetCounter

func GetCounter() *Counter

func NewCounter

func NewCounter(opt *Option) *Counter

func (*Counter) Expire

func (c *Counter) Expire(ctx context.Context, key string, ttl time.Duration) error

func (*Counter) Get

func (c *Counter) Get(ctx context.Context, key string) (int64, error)

func (*Counter) Incr

func (c *Counter) Incr(ctx context.Context, key string, numChain ...int64) (int64, error)

func (*Counter) IsExceeded added in v1.1.61

func (c *Counter) IsExceeded(ctx context.Context, key string, limit int64, incrTagChain ...int64) (bool, error)

func (*Counter) Key

func (c *Counter) Key(k string) string

type Opt

type Opt = Option

type Option

type Option struct {
	RedisClient redis.UniversalClient
	Prefix      string
	TTL         time.Duration
}

Jump to

Keyboard shortcuts

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