Documentation
¶
Index ¶
- type BubbleChart
- func (x BubbleChart) Append(ctx context.Context, entries []Entry, opts ...Option) (err error)
- func (x BubbleChart) GetById(ctx context.Context, ids []string, opts ...Option) (entries []Entry, err error)
- func (x BubbleChart) GetByRank(ctx context.Context, offset, count int32, opts ...Option) (entries []Entry, err error)
- func (x BubbleChart) RemoveById(ctx context.Context, ids []string, opts ...Option) (err error)
- func (x BubbleChart) SetInfo(ctx context.Context, entries []Entry, opts ...Option) (err error)
- func (x BubbleChart) SwapById(ctx context.Context, id1, id2 string, opts ...Option) (err error)
- func (x BubbleChart) SwapByRank(ctx context.Context, rank1, rank2 int32, opts ...Option) (err error)
- func (x BubbleChart) Touch(ctx context.Context, opts ...Option) (err error)
- type Client
- type E
- type Entry
- type Leaderboard
- func (x Leaderboard) GetById(ctx context.Context, ids []string, opts ...Option) (entries []Entry, err error)
- func (x Leaderboard) GetByRank(ctx context.Context, offset, count int32, opts ...Option) (entries []Entry, err error)
- func (x Leaderboard) RandByScore(ctx context.Context, args []RandByScoreArg, opts ...Option) (entries []Entry, err error)
- func (x Leaderboard) RemoveById(ctx context.Context, ids []string, opts ...Option) (err error)
- func (x Leaderboard) Set(ctx context.Context, entries []Entry, opts ...Option) (_ []Entry, err error)
- func (x Leaderboard) SetInfo(ctx context.Context, entries []Entry, opts ...Option) (err error)
- func (x Leaderboard) SetOne(ctx context.Context, entry Entry, opts ...Option) (_ Entry, err error)
- func (x Leaderboard) Touch(ctx context.Context, opts ...Option) (err error)
- type Option
- func WithCapacity(capacity int32) Option
- func WithConstructFrom(name string) Option
- func WithExpire(d time.Duration) Option
- func WithExpireAt(t time.Time) Option
- func WithNoInfo(v bool) Option
- func WithNoTrim(v bool) Option
- func WithPersist(v bool) Option
- func WithSetIncrBy(v bool) Option
- func WithSetOnlyAdd(v bool) Option
- func WithSetOnlyUpdate(v bool) Option
- type Options
- type RandByScoreArg
- type SetOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BubbleChart ¶
type BubbleChart struct {
// contains filtered or unexported fields
}
func GetBubbleChart ¶
func GetBubbleChart(rcli redis.Client, name string, opts ...Option) BubbleChart
func (BubbleChart) GetByRank ¶
func (x BubbleChart) GetByRank( ctx context.Context, offset, count int32, opts ...Option) (entries []Entry, err error)
get entries by range
func (BubbleChart) RemoveById ¶
remove chart entry by id
func (BubbleChart) SwapByRank ¶
func (x BubbleChart) SwapByRank( ctx context.Context, rank1, rank2 int32, opts ...Option) (err error)
swap 2 entries by rank
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (Client) GetBubbleChart ¶
func (cli Client) GetBubbleChart(name string, opts ...Option) BubbleChart
func (Client) GetLeaderboard ¶
func (cli Client) GetLeaderboard(name string, opts ...Option) Leaderboard
type Entry ¶
type Entry struct { Rank int32 `json:"rank" msgpack:"rank"` Id string `json:"id" msgpack:"id"` Info string `json:"info" msgpack:"info"` Score int64 `json:"score" msgpack:"score"` }
Entry代表排行榜中的一条数据 Entry.Rank 从0开始的榜单排名 Entry.Id 对象ID Entry.Score 对象分数,排名依据 Entry.Info 对象的详细信息
type Leaderboard ¶
type Leaderboard struct {
// contains filtered or unexported fields
}
func GetLeaderboard ¶
func GetLeaderboard(rcli redis.Client, name string, opts ...Option) Leaderboard
func (Leaderboard) GetByRank ¶
func (x Leaderboard) GetByRank( ctx context.Context, offset, count int32, opts ...Option) (entries []Entry, err error)
get entries by range
func (Leaderboard) RandByScore ¶
func (x Leaderboard) RandByScore( ctx context.Context, args []RandByScoreArg, opts ...Option) (entries []Entry, err error)
get entries randomly by score
func (Leaderboard) RemoveById ¶
remove chart entry by id
type Option ¶
type Option struct {
// contains filtered or unexported fields
}
func WithCapacity ¶
func WithConstructFrom ¶
func WithExpire ¶
func WithExpireAt ¶
func WithNoInfo ¶
func WithNoTrim ¶
func WithPersist ¶
func WithSetIncrBy ¶
func WithSetOnlyAdd ¶
func WithSetOnlyUpdate ¶
type Options ¶
type Options struct { // 榜单的最大容量 Capacity int32 `msgpack:"capacity,omitempty"` // 默认情况下,在达到榜单最大容量时将淘汰末位对象 // NoTrim修改此行为为超过容量报错 NoTrim bool `msgpack:"no_trim,omitempty"` // 当请求榜单不存在时从指定榜单复制,可以用来制造榜单快照 ConstructFrom string `msgpack:"construct_from,omitempty"` // 在进行榜单复制时忽略Info数据,只保留排名数据 // 还有另外一个作用,查询榜单时指定该参数将不返回Info NoInfo bool `msgpack:"no_info,omitempty"` // 设置过期时间,以秒为单位的Unix时间戳 // 参数为空则不对过期时间进行修改 ExpireAt string `msgpack:"expire_at,omitempty"` // 设置过期时间,从当前时间算起的秒数 // 如果和ExpireAt同时设置,该参数将被忽略 // 参数为空则不对过期时间进行修改 Expire string `msgpack:"expire,omitempty"` // 设置为不过期,不过期是默认行为 // 该参数只为清除Expire(At)设置的超时时间 Persist bool `msgpack:"persist,omitempty"` // 只对Set生效的参数 Set SetOptions `msgpack:"set,omitempty"` }
type RandByScoreArg ¶
type SetOptions ¶
type SetOptions struct { // 只增加新的元素,已有元素不进行更新,OnlyAdd和OnlyUpdate不能同时为true // ZADD.NX OnlyAdd bool `msgpack:"only_add,omitempty"` // 只更新已有元素,不新增元素,OnlyAdd和OnlyUpdate不能同时为true // ZADD.XX OnlyUpdate bool `msgpack:"only_update,omitempty"` // 对分数进行增加而不是替换 // ZADD.INCR IncrBy bool `msgpack:"incr_by,omitempty"` }
只对Set方法生效的参数
Click to show internal directories.
Click to hide internal directories.