Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
redis-rank
Advanced tools
Back-end to generate and manage leaderboards using Redis. Written in TypeScript and Promise-based.
Back-end to generate and manage leaderboards using Redis. Written in TypeScript and Promise-based.
All the library is promise based.
$ npm install redis-rank
Redis 2.6.12 or newer is required. ioredis package is a dependency.
You must provide the ioredis connection object.
See here for more information on how to set it up.
ES5
const Redis = require('ioredis');
const RedisRank = require('redis-rank');
// setup connection
let ioredis_client = new Redis({
host: "127.0.0.1",
port: 6379
});
// create a leaderboard
let lb = new RedisRank.Leaderboard(ioredis_client);
ES6
import { Redis } from 'ioredis';
import { Leaderboard } from 'redis-rank';
// setup connection
let ioredis_client = new Redis({
host: "127.0.0.1",
port: 6379
});
// create a leaderboard
let lb = new Leaderboard(ioredis_client);
All the methods listed here are promises.
// add entries
lb.add("alice", 25);
lb.add("bob", 13);
lb.add("dave", 42);
lb.add("eve", 54);
// update entries
lb.add("bob", 27); // replace score
lb.incr("alice", 10); // increment by 10, now 35
lb.incr("dave", -5); // decrement by 5, now 37
// remove entries
lb.remove("eve"); // eve is no more
// count entries
lb.total(); // number of entries stored: 3
// query entries
lb.peek("bob"); // { id: "bob", score: 27, rank: 2 }
lb.score("dave"); // dave's score: 37
lb.rank("alice"); // alice's rank: 3
lb.at(1); // get entry at a specific rank: { id: "dave", ... }
// list entries
// all of these return an array of entries
// something like [{ id: "...", score: xxx, rank: xx }, ...]
lb.list(5, 10); // entries between ranks 5 and 10 inclusive
lb.top(10); // the top 10 entries. Alias for list(1, max)
lb.around("id", 10); // get 10 entries above and below the queried entry
// remove all entries
lb.clear();
Note: most of the methods will return null
if the entry is not found.
You can peek at the documented code for more information.
TypeScript definitions are available.
No Redis server is required. ioredis-mock is used to mock Redis.
$ npm test
MIT. See LICENSE.
FAQs
Manage real-time leaderboards using Redis
The npm package redis-rank receives a total of 0 weekly downloads. As such, redis-rank popularity was classified as not popular.
We found that redis-rank demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.