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
}
//////////////////////////////////////////////////////////////////////////////
Click to show internal directories.
Click to hide internal directories.