我的想法是,首先把latitude/longitude转化为geo-hash,然后query on geo-hash.
SQL不太合适,因为这个write speed太大了,SQL要不停地更新index,不太可用。
我搜了一下,下面的这个链接里用的是Redis,因为Redis原生支持 Sorted Sets with Range Queries 和 Geospatial Indexes with Radius Queries。
请问在面试的时候,如果不让用现成的产品,请问自己怎么设计类似的功能?大佬们可不可以shed点light?
https://djangostars.com/blog/bui ... tion-based-service/
Data storage — Live location
To process the live driver coordinates, we opted for GEOADD – a Redis command that adds geospatial data — longitude, latitude, and name — to the specified item. The data is stored as a sorted set. When required, we can retrieve the required items (location data) using the query by radius (the above mentioned GEORADIUS).
After an item is added to the set, Redis lets us update its location using the same GEOADD command. When called with existing items in the list, GEOADD updates the spatial data (longitude and latitude) associated with each item with the new values. This allowed us to provide live locations in the application.