package module
Version: v0.1.0 Latest Latest

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

Go to latest
Published: Oct 7, 2022 License: MIT Imports: 2 Imported by: 0




This section is empty.


This section is empty.


func New

func New(limit int, expiresAfter time.Duration) *limiterManager

New returns a limiter manager, this is thread safe but does not lock keys like transactions would.

limit: 			how many unexpired entries a key can have
expiresAfter: 	how long before an entry expires for a key
gcInterval: 	the interval when the underlying cache
				should remove expired keys


type Limiter

type Limiter interface {
	// IsLimited checks if the given key is limited
	IsLimited(key interface{}) bool
	// Increment increments the counter
	Increment(key interface{})
	// Remove clears key from all limits
	Remove(key interface{})
	// Count returns the total amount of values
	// that are not expired
	Count(key interface{}) int

Limiter is an interface to the limiterManager structure. use New(int, time.Duration) to instantiate a new limiter. See limiterManager (scroll down) for more information.

Source Files

Jump to

Keyboard shortcuts

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