-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Hi welcome to 2020 can we have a redis set that is async without bringing in bluebird #1469
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
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! |
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. |
I think we could do without the bluebird now.
The text was updated successfully, but these errors were encountered: