zoltanradics / strapi-connector-redis

[DISCCOUNTINUED] The missing Redis connector for Strapi. By using this third-party (not official Strapi) connector, you can access Redis client on your Strapi instance, therefore you can access your Redis database in your controllers and services. (or wherever Strapi instance is available)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

use xredis instead of node-redis

emahuni opened this issue · 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) }
  });)
}