Due to my "love affair" with sqlite, I did consider this, however, Ilia
suggested that some scheme using shared memory will be the fastest.
If we store the database in the binary equivalent to the format that you
suggested, we can make some very fast lookups by incurring the overhead
of a single PHP function call, rather than a whole bunch of them and
their related syscalls (fseek, fread etc. etc.).
Also, implementing it in C gives us the option of perhaps implementing
some kind of mod_mirror for Apache, so that we can perform intelligent
load balancing before we even hit the PHP engine.
OK, I am not against doing it this way. And I hope the directi data source continues to be a reliable database for ip2country information. We added checks to ensure that the DB is fully downloaded and that it is in the proper format (20 numbers, 3 chars and \n in every record), but it was not in consideration that the data itself can be incorrect. When we started to work with ip-to-country, the db was also only around 400k. Now it is 1.5MB. The question is if this big size is by error, or that 400k DB was not covering as much IPs as this 1.5MB DB does. It's quite hard to beleive that 1.5MB is needed to have this data, as the 400k DB was said to be [nearly] complete. Divyank, can you please comment on this?
Goba