Original: https://redislabs.com/ebook/redis-in-action/part-2-core-concepts-2/ Chapter-5-using-redis-for-application-support/5-3-ip-to-city-and-country-lookup
When we have collected statistical information and logs to Redis, we have collected information about the behavior of our system visitors. But we overlook an important part of visitor behavior-where do visitors come from? In this section we will build a set of functions to parse IP into the region database, and we will write a function to query the IP address used to determine the visitor's city, region, country. Let me see an example.
When fake game company visitors multiply, players have come from all over the world. While tools like Google Analytics have helped companies know the main countries where users come from, they want to know the cities and regions to better understand the users. This is what we do, using a data that resolves to the city with a IP address combined with Redis to find the user location.
We use Redis instead of the traditional relational database, because Redis will be faster in this case. We use Redis to find tables locally because a large number of user information lookups make it a relatively expensive operation to load the table when the app is launched. To get started with our lookup table, you first need to load the table to Redis.
Fake
<redis in action>5.3 ip-to-city and-country Lookup