Location-based service has gained in popularity as smartphones have become increasingly more common. The Geo API has been introduced officially in Redis, since Release 3.2, to support storing and querying geospatial coordinates for these location-related scenarios. In this recipe, we will explore the Geo data type in Redis.
You need to finish the installation of the Redis Server, as we described in the Downloading and installing Redis recipe in Chapter 1, Getting Started with Redis, and connect to the Redis Server by redis-cli
.
To understand how to use the Geo data type, take the following steps:
- Open a Terminal and connect to Redis with
redis-cli
.
- For the demo application Relp, we can add five restaurants in California to a Geo set called
restaurants:CA
, by usingGEOADD
:
127.0.0.1:6379> GEOADD restaurants:CA -121.896321 37.916750 "Olive Garden" -117.910937 33.804047 "P.F. Chang's" -118.508020 34.453276 "Outback Steakhouse" -119.152439 34...