Vaibhav Magon
Vaibhav Magon

Reputation: 1503

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

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.

Upvotes: 3

Views: 2526

Answers (1)

Vaibhav Magon
Vaibhav Magon

Reputation: 1503

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

Upvotes: 7

Related Questions