promisify-redis

Promisify node_redis client in a sane way

Usage no npm install needed!

<script type="module">
  import promisifyRedis from 'https://cdn.skypack.dev/promisify-redis';
</script>

README

promisify-redis

Build Status

Native promises for redis.

Features

  • Native promises
  • Supports multi and batch
  • Doesn't mutate the library

Usage

Wrap the library:

const promisifyRedis = require('promisify-redis');
const redis = promisifyRedis(require('redis'));

const client = redis.createClient();

async function doSomething() {
  await client.set('foo', 'bar');
  return client.get('foo');
}

Or wrap just a single client

const promisifyRedis = require('promisify-redis');
const redis = require('redis');

const client = promisifyRedis(redis.createClient());

Multi

.exec() will return a promise:

await client.multi()
  .set('foo', 'bar')
  .get('foo')
  .exec();

Duplicate

.duplicate() only supports the synchronous version of the original library. It is still synchronous and will return a promisified client.