February 2018
Intermediate to advanced
382 pages
11h 33m
English
In the command ZADD, we can only add new elements, by the option NX, to the set if there are already some elements in it:
127.0.0.1:6379> ZADD ranking:restaurants NX 50 "Olive Garden" (integer) 0 127.0.0.1:6379> ZREVRANGE ranking:restaurants 0 -1 WITHSCORES 1) "Kung Pao House" 2) "213" 3) "Olive Garden" 4) "100" 5) "Longhorn Steakhouse" 6) "88" 7) "Red Lobster" 8) "46" 9) "Outback Steakhouse" 10) "34" 11) "PF Chang's" 12) "23"
Similarly, the option XX allows you to update the set without adding new elements into it. Please take note that these options can only be applied from Redis 3.0.2 or greater.
Another thing regarding ZADD that should be noted is that it is possible to have multiple different elements with the same score. ...
Read now
Unlock full access