February 2018
Intermediate to advanced
382 pages
11h 33m
English
Sometimes we do not want to sort elements by their values, but by their weights that are defined in some external keys. For example, we may need to sort the user's favorite restaurants by ratings defined in keys like restaurnat_rating_200, where 200 is the restaurant ID. This can also be done in SORT:
127.0.0.1:6379> SET "restaurant_rating_200" 4.3 127.0.0.1:6379> SET "restaurant_rating_365" 4.0 127.0.0.1:6379> SET "restaurant_rating_104" 4.8 127.0.0.1:6379> SET "restaurant_rating_455" 4.7 127.0.0.1:6379> SET "restaurant_rating_333" 4.6 127.0.0.1:6379> SORT "user:123:favorite_restaurant_ids" BY restaurant_rating_* DESC 1) "104" 2) "455" 3) "333" 4) "200" 5) "365"
In some scenarios, the values from external keys are more useful. ...
Read now
Unlock full access