Manage real-time leaderboards using Redis
- Lightweight: minimal dependencies, only ioredis is required
- Performance: guaranteed at most one trip to Redis on each function call*, taking advantage of ioredis's pipelining and Lua scripts
- Drop-in replacement: use any existing sorted set as a leaderboard
- Clear interface: Promise-based & provides TypeScript definitions
- Periodic leaderboards: create recurring leaderboards: daily, weekly, monthly, etc or use a custom cycle
- Combine leaderboards: create a matrix of leaderboards: update, filter and retrieve multiple entries in a single call
- Export: export your leaderboards for long-term storage
- Tested: 100% code coverage
$ npm install redis-rank ioredis
Redis 2.6.12 or newer is required. The package ioredis is a peer dependency and must be installed separately.
🔗 Import and connect
const Redis = ;const Leaderboard = ;
let client =host: "127.0.0.1"port: 6379;
You are ready, now read one of the examples linked below!
- Basic leaderboard usage
- Exporting a leaderboard
- Recurring leaderboards
- Custom cycles
- Clean stale leaderboards
- Matrix of leaderboards
- Showcasing leaderboards
- Redis keys
A Redis server in localhost without password is expected.
⚠️ Note: The database #15 will be flushed ⚠️
$ npm test
I tried with ioredis-mock but I experienced some issues with Lua scripts so we have to rely on a real Redis server (which I think is better anyway).
MIT. See LICENSE.