Redis ZRANGEBYSCORE Replacement

Starting with Redis 6.2.0, the ZRANGE command added the REV, BYSCORE, BYLEX and LIMIT options. The addition of the first three options means that the ZRANGE command can now do what the ZREVRANGE, ZRANGEBYSCORE, ZREVRANGEBYSCORE, ZRANGEBYLEX and ZREVRANGEBYLEX commands can do.

As a result, those commands are now deprecated (as of Redis 6.2.0).

Therefore, we should no longer use the ZRANGEBYSCORE command when we need to return a sorted set by score. Instead, we should use the ZRANGE command with the BYSCORE argument.

Read more

Redis ZRANGE Command Explained

In Redis, the ZRANGE command returns the specified range of elements in the sorted set stored at the specified key.

It can perform different types of range queries: by index (rank), by the score, or by lexicographical order.

Read more

Redis ZADD Command Explained

In Redis, the ZADD command is used to add one or more members to a sorted set, or to update the score for members that already exist in the sorted set.

It returns the number of elements added to the sorted set, or the number of elements updated if the CH argument is used.

Read more

How to Allow Duplicate Fields when using HRANDFIELD in Redis

By default, Redis’s HRANDFIELD command returns distinct fields. In other words, it won’t return the same field multiple times – each field that’s returned by the command will only be returned once.

However, we can override this behaviour by using an negative count value for the count argument.

When we pass a negative count argument, the HRANDFIELD command allows non-distinct fields to be returned.

Read more