Wednesday, July 31, 2019

How to make redis client async via bluebird in Node.js

var redis = require('redis')
var client = redis.createClient(port, 'ip', {password: 'password'})
var bluebird = require('bluebird')
bluebird.promisifyAll(redis);

async function main2() {
    console.log('main')

    await client.watchAsync("foo")

    const result = await client.getAsync("foo")
    console.log(`get ${result}`)

    const results = await client.multi().set("foo", "some heavy computation").execAsync()
    console.log(`exec ${results}`)
}

main2()

No comments:

Post a Comment