Originally from: Http://www.infoq.com/cn/news/2015/07/redis-geo
The mobile internet has enhanced people-to-people connections, where location-based services (locations Based service,lbs) play an important role in promoting them. In the mobile Internet environment, each mobile phone has become a location tracking device, providing people with a very rich location services. Whether it is a nearby person, or shake a shake and other familiar applications need lbs in the background support. However, there are many challenges in the process of using location information, such as the inaccurate calculation of neighboring computations. The Redis Geo module is designed to provide accurate and stable location services due to the constant volume of data requests and the fact that the computing of the location services is done by the database.
In the challenge of location services, it is common to calculate whether two locations are adjacent to each other. Location information is composed of a four-tuple, (longitude, latitude, altitude, time), in the use of the process is more commonly used is latitude and longitude. A two-dimensional index is required to perform adjacent calculations. The problem is that the existing two-dimensional index based on simple one-dimensional index and range search implementation, basically only applies to integer query, and does not apply to the similarity query of latitude and longitude. Aware of this difficulty, and with the growing demand for location services, in 2008 Gustavo Niemeyer proposed a geohash, simply a 32-bit coded string to integrate the location into a range of entities that can be searched. Because most databases support scope queries, the location becomes available for lookup and computation. The disadvantage of the original Geohash is that the accuracy of the query is sometimes low, and subsequent developers create 52-bit geohash to meet the needs of customization.
In NoSQL, MongoDB has a better support for location services, and it supports Foursquare and other applications stably. HBase has also introduced tutorials to support the introduction of location services in the app. As a model for excellent NoSQL databases, Redis is slightly weaker in location computing. To this end, Italian programmer Salvatore Sanfilippo ([email protected]) maintains a branch specifically for Redis to add location calculations. After its release, it received a unanimous endorsement in the field, with up to 13,000 stars harvested in just a few months. In Hacker news, many programmers have also expressed the brief encounter of the function of Redis location query, we have discussed the necessity of the existence of Redis Geo, and a number of means that should be improved from performance and query accuracy, and even further contributed Redis Geo's docker image.
More details on the Redis Geo can be found in the documentation page given by Antirez, which includes the basic use of Redis Geo, such as the addition of latitude and longitude, calculation of latitude and longitude, calculation of the inclusion relationship between cities, and many other location computing functions. Antirez further explains how Redis Geo works, and the performance of the module running on benchmark, up to nearly 5 million codecs per second, to meet the needs of most location service applications.
Turn: Redis geo:redis new Location query feature