我下载了GeoLite城市数据库,并能够使用Java访问数据库,以获得IP地址的相应位置信息,方法如下:
File file = new File("C:\\GeoLiteCity.dat");
LookupService lookup = new LookupService(file, LookupService.GEOIP_MEMORY_CACHE);
Location location = lookup.getLocation("123.123.12.34");我的问题是:在生产环境中,以上述方式打开每个IP地址的文件显然是不可取的。如何以生产方式使用此数据库(假设使用了GeoLiteCity.dat)?
任何输入或指针都是非常感谢的。
谢谢和问候!
发布于 2014-06-17 00:12:30
有两项建议:
1. Make the LookupService static (lookup) and available in the memory (Singleton)
2. Load this file (or CSV file version) into a database (New tables, columns etc...)我不确定与将服务加载到内存中并在其上进行搜索相比,数据库是否能够极大地提高性能。有了这些GeoLite每周发布的文件,清理/加载/索引数据库的开销也会增加。
https://stackoverflow.com/questions/24252995
复制相似问题