Geo-proximity with sorted sets
📖 Scenario: You are building a simple location-based service that stores places with their geographic coordinates. You want to find places near a specific location.
🎯 Goal: Create a Redis sorted set to store places with their longitude and latitude. Then, configure a radius distance. Next, query the sorted set to find places within that radius sorted by distance. Finally, complete the setup to return the results with distances.
📋 What You'll Learn
Create a sorted set called
places with three places and their longitude and latitude using GEOADD.Create a variable
radius set to 10 kilometers.Use
GEORADIUS command on places with center longitude 13.361389 and latitude 38.115556, radius radius, unit km, and sort results by distance ascending.Add the option to return distances with the results.
💡 Why This Matters
🌍 Real World
Location-based services like finding nearby restaurants, stores, or landmarks use geo-proximity queries to provide relevant results to users.
💼 Career
Understanding Redis geo commands is useful for backend developers working on location-aware applications, improving user experience with fast and efficient geographic queries.
Progress0 / 4 steps