Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use zscan in Redis using Node.js.?

Tags:

node.js

redis

I want to use 'ZSCAN' command in node.js to hit redis for results. I went thru node-redis-streamify and also other packages of node modules for the same but i am not able to execute this command. It would be great if I could get a sample usage of 'ZSCAN' command using any desired package.

npm package : node-redis-streamify:

Code :

                    var key = 'find:a';
                    var pattern = 'find:' + '*';
                    var count = 2;
                    var zscan = redis.streamified('ZSCAN');
                    zscan(key,pattern,count)
                        .on('data', function (data) {
                            console.log("++++++++++++++++++");
                            console.log(data);
                            console.log("++++++++++++++++++");
                            cb(null,data);
                        })
                        .on('error', function (err) {
                            console.log("Redis Error",err);
                            return err;
                        }).on('end', function () {

                        });

Error:

Redis Error { [Error: ERR invalid cursor] command: 'ZSCAN', code: 'ERR' }

Any leads would be great. Thanks.

like image 536
Vaibhav Magon Avatar asked Feb 01 '26 12:02

Vaibhav Magon


1 Answers

So I posted the question on github and got an answer from there. Here's the link : ZSCAN ISSUE Thanks BridgeAR .

like image 120
Vaibhav Magon Avatar answered Feb 03 '26 05:02

Vaibhav Magon