ranking

package
v1.5.8 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// 跳跃表最大层数
	SKIPLIST_MAXLEVEL = 32
	// 随机概率
	SKIPLIST_P = 0.25
)

Variables

View Source
var (
	RTS = make(map[int16]*RankTree)
)

Functions

func Load

func Load(infos []*DbRankInfo)

func LoadRankTrees

func LoadRankTrees(infos []*DbRankInfo) map[int16]*RankTree

LoadRankTrees 从dump加载排名模块

func ResetRankTree

func ResetRankTree(rtype int16, rank *RankTree)

func SaveRanking

func SaveRanking(rt *RankTree, filename string) error

SaveRanking dump排名模块

Types

type DbRankInfo

type DbRankInfo struct {
	Type      int16
	Id        int64
	Val       int64
	Timestamp int64
}

func Save

func Save() []*DbRankInfo

func SaveRankTrees

func SaveRankTrees(rts map[int16]*RankTree) []*DbRankInfo

SaveRankTrees dump排名模块

type RankInfo

type RankInfo struct {
	Id        int64
	Val       int64
	Rank      int32
	Timestamp int64
}

type RankTree

type RankTree struct {
	EntryMapping map[int64]*RankInfo
	// contains filtered or unexported fields
}

func GetRankTree

func GetRankTree(rtype int16) *RankTree

func LoadRanking

func LoadRanking(filename string) (*RankTree, error)

LoadRanking 从dump加载排名模块

func NewRankTree

func NewRankTree() *RankTree

func (*RankTree) AddRankInfo

func (rt *RankTree) AddRankInfo(uid int64, val int64, timestamp int64)

AddRankInfo 添加新排名信息

func (*RankTree) IncrRankInfo

func (rt *RankTree) IncrRankInfo(uid int64, val int64, timestamp int64)

IncrRankInfo 更新排名信息

func (*RankTree) QueryByRank

func (rt *RankTree) QueryByRank(rank int32) *RankInfo

QueryByRank 根据排名查询信息

func (*RankTree) QueryByRankRange

func (rt *RankTree) QueryByRankRange(min, max int32) []*RankInfo

QueryByRankRange 查询指定范围排名

func (*RankTree) QueryRankInfo

func (rt *RankTree) QueryRankInfo(uid int64) *RankInfo

QueryRankInfo 查询用户排名

func (*RankTree) RemoveRankInfo

func (rt *RankTree) RemoveRankInfo(uid int64) bool

RemoveRankInfo 删除排名信息

Jump to

Keyboard shortcuts

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