counters

package
v0.0.0-...-13c8884 Latest Latest
Warning

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

Go to latest
Published: May 5, 2019 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

计数器: 调用自增接口时, 如果与记录中key相同则增加记录中计数, 否则重新计数 例: 限制每分钟(秒钟)接口访问次数, 以时间为参数调用自增接口, 根据返回值判断是否到上限

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AtomicTimesCounter

type AtomicTimesCounter struct {
	*sync.Mutex
	*TimesCounter
}

func NewAtomicTimesCounter

func NewAtomicTimesCounter() *AtomicTimesCounter

func (*AtomicTimesCounter) GetTimes

func (this *AtomicTimesCounter) GetTimes(key string) int

func (*AtomicTimesCounter) IncTimes

func (this *AtomicTimesCounter) IncTimes(key string) int

type TimesCounter

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

//////////////////////////////////////////////////////////////////////////////

Jump to

Keyboard shortcuts

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