counters

package
v1.2.6 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2023 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Counter

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

func NewCounter

func NewCounter() *Counter

NewCounter create new counter

func (*Counter) GC

func (this *Counter) GC()

GC garbage expired items

func (*Counter) Get

func (this *Counter) Get(key uint64) uint64

Get value of key

func (*Counter) GetKey

func (this *Counter) GetKey(key string) uint64

GetKey get value of string key

func (*Counter) Increase

func (this *Counter) Increase(key uint64, lifeSeconds int) uint64

Increase key

func (*Counter) IncreaseKey

func (this *Counter) IncreaseKey(key string, lifeSeconds int) uint64

IncreaseKey increase string key

func (*Counter) Reset

func (this *Counter) Reset(key uint64)

Reset key

func (*Counter) ResetKey

func (this *Counter) ResetKey(key string)

ResetKey string key

func (*Counter) TotalItems

func (this *Counter) TotalItems() int

TotalItems get items count

func (*Counter) WithGC

func (this *Counter) WithGC() *Counter

WithGC start the counter with gc automatically

type Item

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

func NewItem

func NewItem(lifeSeconds int) *Item

func (*Item) Increase

func (this *Item) Increase() uint64

func (*Item) IsExpired

func (this *Item) IsExpired(currentTime int64) bool

func (*Item) Reset

func (this *Item) Reset()

func (*Item) Sum

func (this *Item) Sum() uint64

type Span

type Span struct {
	Timestamp int64
	Count     uint64
}

func NewSpan

func NewSpan() *Span

Jump to

Keyboard shortcuts

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