If you’re getting an error that reads “ERR numkeys should be greater than 0” in Redis, it’s probably because you’re specifying a wrong value for the first argument when calling the SINTERCARD
command.
To fix this issue, make sure you’re passing a valid non-zero value that matches the number of keys you’re comparing.
Example of Error
Here’s an example of code that produces the error:
SINTERCARD set1 set2 set3
Result:
(error) ERR numkeys should be greater than 0
In this case, I passed the names of three keys, but I forgot to include the numkeys
argument (which should be the first argument).
Solution
To fix the issue, be sure to include the numkeys
argument, and make sure it’s a valid non-zero value that matches the number of keys you’re comparing.
Example:
SINTERCARD 3 set1 set2 set3
Result:
(integer) 2
Here, I provided the correct number of arguments and values and we got the desired result without error.