View on GitHub

Go-leaderboard

A leaderboard library written in Go using redis

Download this project as a .zip file Download this project as a tar.gz file

Leaderboard

A leaderboard written in Go using Redis database.

Features

How to use

Create a new leaderboard or attach to an existing leaderboard named 'highscores': highScore := NewLeaderboard("highscores", 10) //return a Leaderboard: Leaderboard{name:"highscores", pageSize:10}

Adding members to highscores using RankMember(username, score):

    highScore.RankMember("dayvson", 9876)
    highScore.RankMember("arthur", 2000123)
    highScore.RankMember("felipe", 100000)

You can call RankMember with the same member and the leaderboard will be updated automatically:

    highScore.RankMember("dayvson", 7481523)
    //return an user: User{name:"dayvson", score:7481523, rank:1}

Getting a total members on highscores:

    highScore.TotalMembers()
    //return an int: 3

Getting the rank from a member:

    highScore.GetRank("dayvson")
    //return an int: 1

Getting a member from a rank position:

    highScore.GetMemberByRank(2)
    //return an user: User{name:"felipe", score:100000, rank:2}

Getting members around you:

    highScore.GetAroundMe("felipe")
    //return an array of users around you [pageSize]User:

Getting Leaders by page:

    highScore.GetLeaders(1)
    //return an array of users with highest score in a first page (you can specify any page): [pageSize]User

Installation

Install Leaderboard using the "go get" command:

go get github.com/dayvson/go-leaderboard

Testing

make test

Dependencies

Contributing

License

© 2013, Maxwell Dayvson da Silva. Released under the MIT License.