1.5K Star 8K Fork 2K

GVP狮子的魂/ip2region

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

IP2Region.Net

.NET client library for IP2Region

Installation

Install the package with NuGet

Install-Package IP2Region.Net

Usage

using IP2Region.Net.Abstractions;
using IP2Region.Net.XDB;

ISearcher searcher = new Searcher(CachePolicy , "your xdb file path");

Cache Policy Description

Cache Policy Description Thread Safe
CachePolicy.Content Cache the entire xdb data. Yes
CachePolicy.VectorIndex Cache vecotorIndex to speed up queries and reduce system io pressure by reducing one fixed IO operation. Yes
CachePolicy.File Completely file-based queries Yes

XDB File Description

Generate using maker, or download pre-generated xdb files

ASP.NET Core Usage

services.AddSingleton<ISearcher>(new Searcher(CachePolicy , "your xdb file path"));

Performance


BenchmarkDotNet=v0.13.2, OS=macOS 13.4.1 (c) (22F770820d) [Darwin 22.5.0]
Apple M1, 1 CPU, 8 logical and 8 physical cores
.NET SDK=7.0.306
  [Host]     : .NET 6.0.20 (6.0.2023.32017), Arm64 RyuJIT AdvSIMD
  DefaultJob : .NET 6.0.20 (6.0.2023.32017), Arm64 RyuJIT AdvSIMD


Method Mean Error StdDev
CachePolicy_Content 155.7 ns 0.46 ns 0.39 ns
CachePolicy_File 2,186.8 ns 34.27 ns 32.06 ns
CachePolicy_VectorIndex 1,570.3 ns 27.53 ns 22.99 ns

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

Apache License 2.0

马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/lionsoul/ip2region.git
git@gitee.com:lionsoul/ip2region.git
lionsoul
ip2region
ip2region
master

搜索帮助