rank

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Data added in v1.0.2

type Data struct {
	Id       int64
	Score    int64
	Rank     int32
	UpdateTs int64
}

type F64CountRank

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

func (*F64CountRank) DelByRank

func (r *F64CountRank) DelByRank(start int64, stop int64) (err error)

DelScore 删除当前分数

@Description:
@receiver r
@param id
@return err

func (*F64CountRank) DelScore

func (r *F64CountRank) DelScore(id int64) (err error)

DelScore 删除当前分数

@Description:
@receiver r
@param id
@return err

func (*F64CountRank) Delete

func (r *F64CountRank) Delete()

删除当前排行榜

func (*F64CountRank) GetCount added in v1.0.9

func (r *F64CountRank) GetCount()

todo暂时未使用

func (*F64CountRank) GetIdRankNotTs

func (r *F64CountRank) GetIdRankNotTs(id int64) (rankInfo *Data)

获取指定id的当前排名

func (*F64CountRank) GetRankInfosNotTs

func (r *F64CountRank) GetRankInfosNotTs(offset, count int) (list []*Data, err error)

GetRankInfosNotTs 获取0~count跳记录 不根据更新时间来

func (*F64CountRank) IncrScore

func (r *F64CountRank) IncrScore(id int64, score int64) (curScore float64, err error)

IncrScore 对指定ID的分数进行增加,并返回增加后的当前分数。 该方法首先更新成员的更新时间戳,然后增加成员的分数。

参数:

id - 要操作的成员ID。
score - 要增加的分数。

返回值:

curScore - 增加分数后的当前分数。
err - 操作过程中可能发生的错误。

IncrScore 先改redis再改cache

@Description:
@receiver r
@param id
@param score
@return curScore
@return err

func (*F64CountRank) UpdateScore

func (r *F64CountRank) UpdateScore(id int64, score int64) (err error)

updateScore 更新给定ID的分数值。

参数:

id - 需要更新分数的实体ID。
score - 新的分数值。

返回值:

error - 更新过程中可能出现的错误。

该方法首先记录当前时间作为更新时间戳,然后将新的分数值添加到排名系统中。 使用Redis的ZAdd方法来确保操作的原子性和一致性。 UpdateScore 更新分数

@Description:
@receiver r
@param id
@param score
@return err

type Mod

type Mod struct {
}

func New

func New() *Mod

func (*Mod) CreateF64CountRank

func (s *Mod) CreateF64CountRank(name string) *F64CountRank

CreateF64CountRank 创建一个排行榜实例 name: [name:赛季]

func (*Mod) Load

func (s *Mod) Load()

Jump to

Keyboard shortcuts

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