zoltanradics/strapi-connector-redis

use xredis instead of node-redis

emahuni opened this issue · 4 comments

I have noticed that xredis is based on node-redis and has higher maintenance frequency. In fact it supports other things that node-redis doesn't that are kind of recent redis features such as ACL. So why not use xredis instead of node-redis?

@emahuni Hey there, thank you for the suggestion. Can you point me to an xredis npm package which you find reliable to integrate? Thanks!

I pointed it out and created a pull request that does this, check it out. #2

Thank you @emahuni , i found this package when i have read your comment and had the following concern: You are asking me to swap redis, the npm package with 2M+ weekly downloads to xredis which was published 2 weeks ago and has 186 weekly downloads.

that was the concern I also had, when I later noticed but it has several bugs fixed and is actually more active than node-redis. You can see that I even submitted an issue asking the developer to instead contribute to the upstream repo. It is working as expected.
The alternative is to use send_command to try and implement an acl command on top of node-redis. So strapi-connector-redis could add this on top to get to this syntax:

// ACL SETUSER
client.acl(['setuser', 'someusername', 'on', 'nopass', '~*', '+@all', '-@dangerous'], function (err, succ) {
 
    if (err) { console.error(err) }
 
    if (succ) { console.log(succ) }
 
});
 
// ACL DELUSER
client.acl(['deluser', 'someusername'], function (err, succ){
 
    if (err) { console.error(err) }
 
    if (succ) { console.log(succ) }
});

by just adding a wrapper function that calls this command like so:

client.acl = function(args, callback) {
  return client.send_command('acl', ...args,  function (err, succ){
    if (err) { console.error(err) }
 
    if (succ) { console.log(succ) }
  });)
}