Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including promised-redis with all npm packages installed. Try it out:

var promisedRedis = require("promised-redis")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

promised-redis v0.10.0

Promise/RxJS wrapper for Node Redis Client

Promised Redis

Build Status

Promise and RxJS wrapper for Node Redis Client

Install

npm install --save redis promised-redis

Featured Redis client functions

Everything. It's proxying the Redis client.

Basic usage

// Initiate a Redis connection
const redis = require('promised-redis');
// If no connection options are passed, connection will default to localhost
// or use REDIS_HOST, REDIS_PORT and REDIS_DB environment variables.
const database = redis({
  host: '127.0.0.1',
  port: 6379,
  db: 0
});
// or if your options comes from a promise
const database = redis(some_promise_that_resolves_an_options_object);

// Execute some Redis commands
database.get('some-key')
.then(value => {
  //
});

Subscribing on channels with RxJS

const redis = require('promised-redis');
const pub = redis();
const sub = redis();

sub.on('subscribe', () => {
  pub.publish('some-channel', '1 message');
  pub.publish('some-other-channel', '2 message');
  pub.publish('some-channel', '3 message');
});

sub.listen('some-channel')
  .take(2)
  .toArray()
  .toPromise()
  .then(messages => {
    expect(messages.length).to.equal(2);
    expect(messages[0]).to.equal('1 message');
    expect(messages[1]).to.equal('3 message');
  });
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free