promisify-redis
v0.0.5
Published
Promisify node_redis client in a sane way
Downloads
19
Readme
promisify-redis
Native promises for redis.
Features
- Native promises
- Supports
multi
andbatch
- 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.