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 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.