Fix: “ERR wrong number of arguments for ‘spop’ command” in Redis

If you’re getting an error that reads “ERR wrong number of arguments for ‘spop’ command” in Redis, it’s because you’re calling the SPOP command with the wrong number of arguments.

At the time of writing, I find that I only get this argument when I pass no arguments. If I pass too many, I get a different error.

In any case, to fix this issue, be sure to pass at least one argument to the command (and at the time of writing, no more than two).

Read more

2 Ways to Return a Random Member from a Redis Set

Redis provides us with two commands that allow us to get one or more random members from a given set – SRANDMEMBER and SPOP.

Actually, the commands are slightly different in that one deletes the random member whereas the other doesn’t, and so the command you choose will depend on whether or not you want to delete the random member at the same time.

Read more

Fix: “ERR wrong number of arguments for ‘sismember’ command” in Redis

If you’re getting an error that reads “ERR wrong number of arguments for ‘sismember’ command” in Redis, it’s because you’re calling the SISMEMBER command with the wrong number of arguments.

To fix this issue, make sure you’re passing the correct number of arguments. At the time of writing, the correct number of arguments for this command is two.

Read more

Redis SUNIONSTORE Command Explained

In Redis, the SUNIONSTORE command does the same thing that SUNION does, except that it stores the result in a key. More specifically, it takes the members of the set resulting from the union of all of the given sets, and stores them in the specified key.

Read more