Documentation ¶
Index ¶
- type Client
- func (c *Client) GetAroundMe(ctx context.Context, leaderboardID string, pageSize int, memberID string, ...) ([]*Member, error)
- func (c *Client) GetAroundScore(ctx context.Context, leaderboardID string, pageSize int, score int64, ...) ([]*Member, error)
- func (c *Client) GetLeaders(ctx context.Context, leaderboardID string, pageSize, page int, order string) ([]*Member, error)
- func (c *Client) GetMember(ctx context.Context, leaderboardID string, memberID string, order string, ...) (*Member, error)
- func (c *Client) GetMembers(ctx context.Context, leaderboardID string, memberIDs []string, order string, ...) ([]*Member, error)
- func (c *Client) GetMembersByRange(ctx context.Context, leaderboard string, startOffset int, endOffset int, ...) ([]*Member, error)
- func (c *Client) GetRank(ctx context.Context, leaderboardID string, memberID string, order string) (int, error)
- func (c *Client) GetTopPercentage(ctx context.Context, leaderboardID string, pageSize, amount, maxMembers int, ...) ([]*Member, error)
- func (c *Client) IncrementMemberScore(ctx context.Context, leaderboardID string, memberID string, increment int, ...) (*Member, error)
- func (c *Client) Ping(ctx context.Context) (string, error)
- func (c *Client) RemoveLeaderboard(ctx context.Context, leaderboardID string) error
- func (c *Client) RemoveMember(ctx context.Context, leaderboardID string, memberID string) error
- func (c *Client) RemoveMembers(ctx context.Context, leaderboardID string, memberIDs []interface{}) error
- func (c *Client) SetMemberScore(ctx context.Context, leaderboardID string, memberID string, score int64, ...) (*Member, error)
- func (c *Client) SetMembersScore(ctx context.Context, leaderboardID string, members Members, prevRank bool, ...) error
- func (c *Client) TotalMembers(ctx context.Context, leaderboardID string) (int, error)
- func (c *Client) TotalPages(ctx context.Context, leaderboardID string, pageSize int) (int, error)
- type Member
- type MemberNotFoundError
- type Members
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents the leaderboard manager object. Capable of managing multiple leaderboards.
func NewClient ¶
func NewClient(host string, port int, password string, db int, connectionTimeout int) (*Client, error)
NewClient creates a leaderboard prepared to receive commands (host, port, password, db and connectionTimeout are used for connecting to Redis)
func NewClientWithRedis ¶
NewClientWithRedis creates a leaderboard using an already connected tfg Redis
func (*Client) GetAroundMe ¶
func (c *Client) GetAroundMe(ctx context.Context, leaderboardID string, pageSize int, memberID string, order string, getLastIfNotFound bool) ([]*Member, error)
GetAroundMe returns a page of results centered in the member with the given ID
func (*Client) GetAroundScore ¶
func (c *Client) GetAroundScore(ctx context.Context, leaderboardID string, pageSize int, score int64, order string) ([]*Member, error)
GetAroundScore returns a page of results centered in the score provided
func (*Client) GetLeaders ¶
func (c *Client) GetLeaders(ctx context.Context, leaderboardID string, pageSize, page int, order string) ([]*Member, error)
GetLeaders returns a page of members with rank and score
func (*Client) GetMember ¶
func (c *Client) GetMember(ctx context.Context, leaderboardID string, memberID string, order string, includeTTL bool) (*Member, error)
GetMember returns the score and the rank of the member with the given ID
func (*Client) GetMembers ¶
func (c *Client) GetMembers(ctx context.Context, leaderboardID string, memberIDs []string, order string, includeTTL bool) ([]*Member, error)
GetMembers returns the score and the rank of the members with the given IDs
func (*Client) GetMembersByRange ¶
func (c *Client) GetMembersByRange(ctx context.Context, leaderboard string, startOffset int, endOffset int, order string) ([]*Member, error)
GetMembersByRange for a given leaderboard
func (*Client) GetRank ¶
func (c *Client) GetRank(ctx context.Context, leaderboardID string, memberID string, order string) (int, error)
GetRank returns the rank of the member with the given ID
func (*Client) GetTopPercentage ¶
func (c *Client) GetTopPercentage(ctx context.Context, leaderboardID string, pageSize, amount, maxMembers int, order string) ([]*Member, error)
GetTopPercentage of members in the leaderboard.
func (*Client) IncrementMemberScore ¶
func (c *Client) IncrementMemberScore(ctx context.Context, leaderboardID string, memberID string, increment int, scoreTTL string) (*Member, error)
IncrementMemberScore sets the score to the member with the given ID
func (*Client) RemoveLeaderboard ¶
RemoveLeaderboard removes a leaderboard from redis
func (*Client) RemoveMember ¶
RemoveMember removes the member with the given publicID from the leaderboard
func (*Client) RemoveMembers ¶
func (c *Client) RemoveMembers(ctx context.Context, leaderboardID string, memberIDs []interface{}) error
RemoveMembers removes the members with the given publicIDs from the leaderboard
func (*Client) SetMemberScore ¶
func (c *Client) SetMemberScore(ctx context.Context, leaderboardID string, memberID string, score int64, prevRank bool, scoreTTL string) (*Member, error)
SetMemberScore sets the score to the member with the given ID
func (*Client) SetMembersScore ¶
func (c *Client) SetMembersScore(ctx context.Context, leaderboardID string, members Members, prevRank bool, scoreTTL string) error
SetMembersScore sets the scores of the members with the given IDs
func (*Client) TotalMembers ¶
TotalMembers returns the total number of members in a given leaderboard
type Member ¶
type Member struct { PublicID string `json:"publicID"` Score int64 `json:"score"` Rank int `json:"rank"` PreviousRank int `json:"previousRank"` ExpireAt int `json:"expireAt"` }
Member maps an member identified by their publicID to their score and rank
type MemberNotFoundError ¶
MemberNotFoundError indicates member was not found in Redis
func NewMemberNotFound ¶
func NewMemberNotFound(leaderboardID, memberID string) *MemberNotFoundError
NewMemberNotFound returns a new error for member not found
func (*MemberNotFoundError) Error ¶
func (e *MemberNotFoundError) Error() string