javascript - node js app with redis backend - how to send a "SCAN" command -


i've installed redis client node application. package information follows:

me@mydevbox:/var/www/html/node/test$ cat package.json  {   "name": "test",   "version": "0.0.0",   "private": true,   "scripts": {     "start": "node ./bin/www"   },   "dependencies": {     "body-parser": "~1.13.2",     "cookie-parser": "~1.3.5",     "debug": "~2.2.0",     "ejs": "~2.3.3",     "express": "~4.13.1",     "morgan": "~1.6.1",     "redis": "^2.6.2",     "serve-favicon": "~2.3.0"   } } 

i need run following command in node js application:

127.0.0.1:6379> scan 0 match widget:914* 1) "0" 2) 1) "widget:9145090003_13:00_17:00"    2) "widget:9145090003_00:00_00:00"    3) "widget:9145090003_08:00_12:00" 127.0.0.1:6379>  

but i've been reading docs , it's not clear how this. far, using samples, i've written following code:

var client = require('redis').createclient();  client.on('error', function (err) {   console.log('error ' + err); }); 

but haven't found generic method allows me send various redis commands. reference i'm using:

https://www.npmjs.com/package/redis 

i'm googling around see other references can find... suggestions appreciated.

thanks

edit 1

i've tried send_command, , i'm getting back... don't quite know how query object. feels though it's empty...

here's i've tried:

client.send_command("scan", [0,"match", "widget:914*"], function(err, reply) {          console.log(reply[0].length);         console.log(reply[1].length);  }); 

that returns:

me@mydev:/var/www/html/node/test$ debug=test:* npm start  > test@0.0.0 start /var/www/html/node/test > node ./bin/www  attempting scan ...   translatedid:server listening on port 3000 +0ms 1 0 

i tried this:

client.send_command("scan", [0,"match", "widget:914*"], function(err, reply) {     (var = 0; < reply.length; i++) {         console.log("variable type item " + + " is: " + typeof(reply));         console.log("properties item " + + " are: " + object.getownpropertynames(reply[i]).sort());          }   }); 

which returns:

> test@0.0.0 start /var/www/html/node/test > node ./bin/www  attempting scan ...   test listening on port 3000 +0ms variable type item 0 is: object properties item 0 are: 0,length variable type item 1 is: object properties item 1 are: length 

but can't seem figure out how @ keys.

edit 2

i had change this:

 client.send_command("scan", [0,"match", "widget:914*"], function(err, reply) { 

to this:

client.send_command("scan", [0,"match", "widget:914*"], function(err, reply) { 

stupid mistake.

node_redis , ioredis both support scan command directly, please revisit latest release again.


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -