Redis leaderboard for node.js
scoreboard is a light weight leaderboard for node.js. It can be used keep score and ranks between multiple objects and scoring types. It is backed by Redis and sorted sets.
- Trending Charts
- Realtime Charts
- Historical Charts
- Game mechanics
$ npm install scoreboard
var scoreboard = require'scoreboard'var Score = scoreboardScore;var scores = ;
var client = rediscreateClient1234 '192.168.100.1';clientauth'somethingsecret';return client;;
Awarding point to an object is simple. Scoreboard supports multiple leaderboards, and is are partitioned by different a
scoresindex'monsters' 100 'edward';scoresindex'aliens' 100 'edward';scoresindex'monsters' 50 'nancy';scoresindex'aliens' 200 'nancy';
To perform a query against the scoreboard to find the leaders, you simple use
Score#leader with a list of keys, and invoke
run with a callback to fetch the results
Find leader in just
Find leader in both
aliens. The scores across the two sets are totalled together
Score are stored in Redis on two types of buckets,
days. Obviously the
overall buckets are used to track scores thoughout the entire life of the scoreboard. But
day buckets allow for more percise queries.
This will return the leaderboard for
scoresleaders keys:'monsters''aliens' date: $start: '1/1/2012' $end: '1/31/2012'runconsole.logleaderboard;;
Paginations is super easy with scoreboard. All you need is
This will return the top 0 - 100 of the time series leaderboard
scoresleaders keys:'monsters''aliens' date: $start: '1/1/2012' $end: '1/31/2012'skip0limit100runconsole.logleaderboard;;
(The MIT License)
Copyright (c) 2012 Edward Chan <firstname.lastname@example.org>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.