2021-06-30 20:01:00 +08:00
|
|
|
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
|
|
|
|
|
|
|
|
|
package metrics
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/cespare/xxhash"
|
|
|
|
|
"strconv"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type Stat struct {
|
|
|
|
|
ServerId int64
|
|
|
|
|
Keys []string
|
|
|
|
|
Hash string
|
|
|
|
|
Value int64
|
|
|
|
|
Time string
|
|
|
|
|
|
|
|
|
|
keysData []byte
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-01 10:39:56 +08:00
|
|
|
func (this *Stat) Sum(version int32, itemId int64) {
|
|
|
|
|
this.Hash = strconv.FormatUint(xxhash.Sum64String(strconv.FormatInt(this.ServerId, 10)+"@"+string(this.keysData)+"@"+this.Time+"@"+strconv.Itoa(int(version))+"@"+strconv.FormatInt(itemId, 10)), 10)
|
2021-06-30 20:01:00 +08:00
|
|
|
}
|