Documentation ¶
Index ¶
- type Counter
- func (slf *Counter[K, V]) Add(key K, value V, expired ...time.Duration)
- func (slf *Counter[K, V]) AddWithMark(mark, key K, value V, expired time.Duration)
- func (slf *Counter[K, V]) Get(key K) V
- func (slf *Counter[K, V]) GetCounts() map[K]V
- func (slf *Counter[K, V]) GetSubCounters() map[K]*Counter[K, V]
- func (slf *Counter[K, V]) Reset(key K)
- func (slf *Counter[K, V]) ResetAll()
- func (slf *Counter[K, V]) ResetExpired(key K)
- func (slf *Counter[K, V]) ResetExpiredMark(mark, key K)
- func (slf *Counter[K, V]) ResetMark(mark, key K)
- func (slf *Counter[K, V]) Shadow() *Shadow[K, V]
- func (slf *Counter[K, V]) SubCounter(key K) *Counter[K, V]
- type Shadow
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Counter ¶
type Counter[K comparable, V generic.Number] struct { // contains filtered or unexported fields }
Counter 计数器
func NewCounter ¶
func NewCounter[K comparable, V generic.Number]() *Counter[K, V]
NewCounter 创建一个计数器
func (*Counter[K, V]) Add ¶
Add 添加计数
- 当设置了 expired 时,在 expired 时间内,不会重复计数
- 需要注意的是,当第一次设置了 expired,第二次未设置时,第二次的计数将生效
func (*Counter[K, V]) AddWithMark ¶
AddWithMark 添加计数,根据 mark 判断是否重复计数
func (*Counter[K, V]) GetCounts ¶
func (slf *Counter[K, V]) GetCounts() map[K]V
GetCounts 获取计数器的所有计数
func (*Counter[K, V]) GetSubCounters ¶
GetSubCounters 获取计数器的所有子计数器
func (*Counter[K, V]) Reset ¶
func (slf *Counter[K, V]) Reset(key K)
Reset 重置特定 key 的计数
- 当 key 为一个子计数器时,将会重置该子计数器
func (*Counter[K, V]) ResetExpired ¶
func (slf *Counter[K, V]) ResetExpired(key K)
ResetExpired 重置特定 key 的过期时间
func (*Counter[K, V]) ResetExpiredMark ¶ added in v0.0.31
func (slf *Counter[K, V]) ResetExpiredMark(mark, key K)
ResetExpiredMark 重置特定 mark 的 key 的过期时间
func (*Counter[K, V]) ResetMark ¶ added in v0.0.31
func (slf *Counter[K, V]) ResetMark(mark, key K)
ResetMark 重置特定 mark 的 key 的计数
func (*Counter[K, V]) SubCounter ¶
SubCounter 获取子计数器
Click to show internal directories.
Click to hide internal directories.