bucket

package
v0.0.0-...-9f36605 Latest Latest
Warning

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

Go to latest
Published: May 29, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenExpiry

func GenExpiry(curTime int64, ttl int32) int64

* ttl in seconds, return expiry in Nano

Types

type KeyBucket

type KeyBucket struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewKeyBucket

func NewKeyBucket(clock clock.Clock) *KeyBucket

func (*KeyBucket) GetEntry

func (b *KeyBucket) GetEntry(key string) *KeyEntry

func (*KeyBucket) Incr

func (b *KeyBucket) Incr(key string, count int32, limit int32, window int32) (bool, int64, bool)

func (*KeyBucket) Lookup

func (b *KeyBucket) Lookup() map[string]*KeyEntry

func (*KeyBucket) Sync

func (b *KeyBucket) Sync(key string, count int32, expiry int64)

type KeyEntry

type KeyEntry struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewEntry

func NewEntry(count int32, expires int64, clock clock.Clock) *KeyEntry

func (*KeyEntry) Count

func (e *KeyEntry) Count() int32

func (*KeyEntry) Expired

func (e *KeyEntry) Expired() bool

func (*KeyEntry) Expiry

func (e *KeyEntry) Expiry() int64

func (*KeyEntry) Incr

func (e *KeyEntry) Incr(count int32) int32

* return total count and curr second count

func (*KeyEntry) LastModified

func (e *KeyEntry) LastModified() int64

func (*KeyEntry) ReInit

func (e *KeyEntry) ReInit(count int32, expires int64, clock clock.Clock)

func (*KeyEntry) Sync

func (e *KeyEntry) Sync(count int32) int32

Jump to

Keyboard shortcuts

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