hotkeymgr

package
v0.0.0-...-b133f75 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HotKey

type HotKey struct {
	Key   string
	Count int64
}

type HotKeyMgr

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

func NewHotKeyMgr

func NewHotKeyMgr(size int, duration time.Duration) *HotKeyMgr

func (*HotKeyMgr) AddRequest

func (hkm *HotKeyMgr) AddRequest(key string)

func (*HotKeyMgr) GetHotKeyCache

func (hkm *HotKeyMgr) GetHotKeyCache() map[string]int64

func (*HotKeyMgr) GetHotKeyFromCache

func (hkm *HotKeyMgr) GetHotKeyFromCache(key string) (int64, bool)

func (*HotKeyMgr) MergeBucketsToHeap

func (hkm *HotKeyMgr) MergeBucketsToHeap()

func (*HotKeyMgr) Start

func (hkm *HotKeyMgr) Start(topK, threshold int, duration time.Duration)

func (*HotKeyMgr) UpdateTopK

func (hkm *HotKeyMgr) UpdateTopK(topK int, threshold int64)

type MaxHeap

type MaxHeap []HotKey

func NewMaxHeap

func NewMaxHeap() *MaxHeap

func (MaxHeap) Len

func (h MaxHeap) Len() int

func (MaxHeap) Less

func (h MaxHeap) Less(i, j int) bool

func (*MaxHeap) Pop

func (h *MaxHeap) Pop() interface{}

func (*MaxHeap) Push

func (h *MaxHeap) Push(x interface{})

func (MaxHeap) Swap

func (h MaxHeap) Swap(i, j int)

type SliderWindow

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

func NewSliderWindow

func NewSliderWindow(size int, windowsDuration time.Duration) *SliderWindow

func (*SliderWindow) Add

func (sw *SliderWindow) Add(key string)

Add 更新当前时间的桶

func (*SliderWindow) GetBucketIndex

func (sw *SliderWindow) GetBucketIndex(currentTime int64) int

func (*SliderWindow) MergeBucketsToHeap

func (sw *SliderWindow) MergeBucketsToHeap(h *MaxHeap)

MergeBucketsToHeap 将所有桶中的商品数据合并到大顶堆中

Jump to

Keyboard shortcuts

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