PHP - *fast* serialize/unserialize?

前端 未结 8 1782
死守一世寂寞
死守一世寂寞 2021-02-19 04:54

I have a PHP script that builds a binary search tree over a rather large CSV file (5MB+). This is nice and all, but it takes about 3 seconds to read/parse/index the file.

<
8条回答
  •  佛祖请我去吃肉
    2021-02-19 05:22

    First you have to change the way your program works. divide CSV file to smaller chunks. This is an IP datastore i assume. .

    Convert all IP addresses to integer or long.

    So if a query comes you can know which part to look. There are functions to do this. So 0 to 2^32 convert all IP addresses into 5000K/50K total 100 smaller files. This approach brings you quicker serialization.

    Think smart, code tidy ;)

提交回复
热议问题