
What is Ip2 region?
ip2 region v2.0 -is an offline IP address location library and IP location data management framework with a query efficiency of 10 microseconds. It provides xdb data generation and query client implementation in many major programming languages.
application scenarios
Ip2 region is widely used in various scenarios that require IP address location. For example, it can be used to detect and prevent attacks from IP addresses in certain regions or countries, and can locate specific geographical locations based on users 'IP addresses. Data analysis and statistics can be performed based on the geographical location information of IP addresses, such as counting the number of users in a certain area.
functional properties
1. Standardized data format
The region information of each IP data segment has a fixed format: country| regional| provinces| city| ISP, only most of the data of China is accurate to the city, some data of other countries can only be located to the country, and the options before and after are all 0.
2. Data deduplication and compression
The xdb format generator will automatically deduplicate and compress some data. By default, all IP data will be generated. The ip2region.xdb database is 11MiB. As the data detail increases, the database size will gradually increase.
3. Speed query response
Even for queries based entirely on xdb files, the response time for a single query is ten microseconds. Memory accelerated queries can be enabled in the following two ways:
vIndex index caching: Use a fixed memory space of 512KiB to cache vector index data, reducing one IO disk operation and keeping the average query efficiency stable between 10-20 microseconds. xdb entire file cache: Load the entire xdb file into memory, and the memory consumption is equivalent to the xdb file size. There is no disk IO operation, and maintain microsecond query efficiency.
4. IP data management framework
xdb in v2.0 format supports hundreds of millions of IP data segment lines, and region information can also be completely customized. For example, you can add data for specific business requirements to the region, such as GPS information/international unified regional information code/zip code, etc. That means you can completely use ip2 region to manage your own IP location data.
How to use it in C#?
- Install the NuGet package IP2Region.Net.
Install-Package IP2Region.Net
- Query using API is very simple!
using IP2Region.Net.XDB;
Searcher searcher = new Searcher();
searcher.Search("IP地址");
** Dependency injection **
services.AddSingleton<ISearcher,Searcher>();
** Performance **
