Node-redis: Hi welcome to 2020 can we have a redis set that is async without bringing in bluebird

Created on 11 Oct 2019  ·  10Comments  ·  Source: NodeRedis/node-redis

I think we could do without the bluebird now.

Feature Request duplicate

Most helpful comment

This is a really unprofessional way to ask for a feature request in a FOSS library. If you're so consumed with having access to this feature why don't you do the polite or productive thing and either open a PR with the change that you think will help the community, write your own redis client, or work with the maintainers to do the above. Opening a snarky one liner issue where you just complain that things aren't how you think they should be isn't helpful or productive to the community and it reflects poorly upon yourself.

All 10 comments

It's still 2019.

There seems to be no way to have typed definitions of Redis in typescript with Promises enabled (Except creating definition files of course). So I really hope an update comes up for this :(

@xtianus79 You know you can use util.promisify, right?

Admittedly, you need to do it on a per-command basis and MULTI/EXEC is... inelegant syntax wise.

This is a really unprofessional way to ask for a feature request in a FOSS library. If you're so consumed with having access to this feature why don't you do the polite or productive thing and either open a PR with the change that you think will help the community, write your own redis client, or work with the maintainers to do the above. Opening a snarky one liner issue where you just complain that things aren't how you think they should be isn't helpful or productive to the community and it reflects poorly upon yourself.

@BobbieBarker it was meant to be funny no harm intended!
Also me, what you're saying applies to you as well.

Is this okay?

const { promisify } = require('util');
const redis = require('redis');

let client = new Proxy(redis.createClient(), {
    get: (target, propKey, receiver) => {
        let asyncKey = typeof propKey === 'string' && propKey.endsWith('Async') && propKey.slice(0, -5);
        if (asyncKey) {
            return promisify(Reflect.get(target, asyncKey, receiver)).bind(receiver);
        }
        return Reflect.get(target, propKey, receiver);
    }
});

// use
client.setAsync('string key', 'val').then(res => {
    console.log(res);
});

Thanks @yi-huan that is a good solution but it isn't a complete promised based solution

@xtianus79 @Innomalist I wrote a client which might be what you're looking for - it wraps this library (its only dependency) and adds promise and typescript support: https://npmjs.com/package/handy-redis.

@mmkal does it do clusters?

@BobbieBarker thank you very much for your considering words!

The main issue is indeed that this project is not supported in any way and that allowed very little maintenance.

I am closing this as duplicate of #864. I actually worked on a promise based client a while back but using promises was slower at that point of time and thus I did not publish it. I'll push the code later on to a feature branch.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

strumwolf picture strumwolf  ·  4Comments

lemon707 picture lemon707  ·  3Comments

michaelwittig picture michaelwittig  ·  3Comments

dotSlashLu picture dotSlashLu  ·  5Comments

adamgajzlerowicz picture adamgajzlerowicz  ·  4Comments