Fix “WRONGTYPE Operation against a key holding the wrong kind of value” When Calling SUNION or SUNIONSTORE in Redis

If you’re getting an error that reads “WRONGTYPE Operation against a key holding the wrong kind of value” when calling either the SUNION command or the SUNIONSTORE command in Redis, it’s probably because you’re passing a key with the wrong data type.

To fix this issue, make sure that each key that you pass holds a set.

Read more

How to Get a Key’s Type in Redis

If you know the name of a key in Redis, but you want to find out it’s type (eg, string, list, hash, set, etc), look no further than the TYPE command. This command returns the string representation of the type of the value at the given key.

Read more

Fix: “ERR syntax error” when using SPOP in Redis

If you’re getting an error that reads “ERR syntax error” in Redis, it could be because you’re calling the SPOP command with too many arguments.

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

Read more

How to Get a Substring in Redis

If we have a key that holds a string value, we can use the GETRANGE command to get a substring from that value.

Redis also has a SUBSTR command that does the same thing, but that was deprecated in Redis 2.0.0, in favour of the GETRANGE command.

Read more