Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hi welcome to 2020 can we have a redis set that is async without bringing in bluebird #1469

Closed
xtianus79 opened this issue Oct 11, 2019 · 10 comments
Labels

Comments

@xtianus79
Copy link

I think we could do without the bluebird now.

@stockholmux
Copy link
Contributor

It's still 2019.

@mirnpnh
Copy link

mirnpnh commented Oct 18, 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 :(

@stockholmux
Copy link
Contributor

@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.

@BobbieBarker
Copy link

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.

@xtianus79
Copy link
Author

xtianus79 commented Oct 29, 2019

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

@yi-huan
Copy link

yi-huan commented Nov 19, 2019

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);
});

@xtianus79
Copy link
Author

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

@mmkal
Copy link

mmkal commented Jan 3, 2020

@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.

@xtianus79
Copy link
Author

@mmkal does it do clusters?

@BridgeAR
Copy link
Contributor

BridgeAR commented Feb 5, 2020

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants