Native promises for redis.
multi
and batch
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());
.exec()
will return a promise:
await client.multi()
.set('foo', 'bar')
.get('foo')
.exec();
.duplicate()
only supports the synchronous version of the original library. It is still synchronous and will return a promisified client.