Redis Extension 🍬

This a library, which provides additional features to the
redis client library.
Table of Contents
Installation
npm install redis-extension --save
Features
- ️️🕵️♀️ Watcher - Watch for specific events
- 🏆 ScoreBoard - Store keys by score.
- 🔌 JsonAdapter - Stringify value as json string on set and parse on get
Usage
Watcher
import {
Watcher,
createClient
} from "redis-extension";
const client = createClient();
client.set('foo', 'bar', 'PX', '500');
const watcher = new Watcher(client, {
pattern: 'foo*',
});
watcher.on('expire', (key) => {
console.log(key);
});
await watcher.start();
ScoreBoard
import {
createClient,
ScoreBoard,
} from "redis-extension";
const client = createClient();
const scoreBoard = new ScoreBoard(client, {
key: 'users-online'
});
scoreBoard.add(1);
scoreBoard.add(2);
const output = scoreBoard.get({
sort: 'DESC'
});
console.log(output);
The score
property represents the unix timestamp by default if it has not been set otherwise.
JsonAdapter
import {
JsonAdapter,
createClient
} from "redis-extension";
const client = createClient();
const jsonAdapter = new JsonAdapter(client);
await jsonAdapter.set('51f3509d-871b-48ad-af15-d1c9eb941362', {
name: 'admin',
});
const payload = jsonAdapter.get('51f3509d-871b-48ad-af15-d1c9eb941362');
console.log(payload);
License
Made with 💚
Published under MIT License.