简体   繁体   中英

redis in node.js zadd arguments

I have this line in node.js, but i get wrong number of arguments. In redis-cli it would be easy, etg test 10 2, but for some reason it wont work here.

example:

convensation:convensationIds:user:23984 294874 1

my code:

 redis_client.zadd(['convensation:convensationIds:user:' + data.from ,convensationId ,data.to]);

error:

RR wrong number of arguments for 'zadd' command

EDIT:

i also tried

redis_client.zadd('convensation:convensationIds:user:' + data.from ,convensationId ,data.to);

but got the same error as above.

You're passing just one argument, namely an array. Try passing the values of that array as proper arguments:

redis_client.zadd('convensation:convensationIds:user:' + data.from ,convensationId ,data.to);

zadd takes three parameters:

  1. The first is the name of the Z set
  2. The second is number, most probably 0
  3. The third is new value

Example: client.zadd("job", 0 , string_job);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM