优化排行榜RankService,新增mongodb持久化Module

This commit is contained in:
orgin
2022-11-23 09:45:26 +08:00
parent 5bea050f63
commit c7e0fcbdbb
7 changed files with 623 additions and 79 deletions

View File

@@ -93,7 +93,7 @@ func (rd *rankDataHeap) PopExpireKey() uint64{
return rankData.Key
}
func (rd *rankDataHeap) PushOrRefreshExpireKey(key uint64){
func (rd *rankDataHeap) PushOrRefreshExpireKey(key uint64,refreshTimestamp int64){
//1.先删掉之前的
expData ,ok := rd.mapExpireData[key]
if ok == true {
@@ -105,7 +105,7 @@ func (rd *rankDataHeap) PushOrRefreshExpireKey(key uint64){
//2.直接插入
expData = expireDataPool.Get().(*ExpireData)
expData.Key = key
expData.RefreshTimestamp = time.Now().UnixNano()
expData.RefreshTimestamp = refreshTimestamp
rd.mapExpireData[key] = expData
heap.Push(rd,expData)