search

Home  >  Q&A  >  body text

php - Four txts a, b, c, and d. Compare how many of the three txts bcd are in a. These four files are about 250M.

  1. The rules are as follows:

    < /p>

I have tested it myself and set up these two ini_set('memory_limit', '-1');set_time_limit(0);, and then after running it for a long time, it reported a 500 error. Please help!!!

怪我咯怪我咯2828 days ago463

reply all(3)I'll reply

  • 仅有的幸福

    仅有的幸福2017-05-16 13:09:52

    Lots of data. It is estimated that the database will die easily. For simple comparison, first write a script to save the data into redis. The cache key of table a is a.0 a.1 a.2 or something, b.000000036 or something. The last two rules remain the same. After importing, determine the total number of data in a

    Write a for loop

    $redis= new Redis();
    $Acount = 100000; //a的总数
    $num  = 1;
    $chkary = [1,2,3,4,5,6,7,8,9];//判断用的数组
    for ($i=0;$i<=$Acount;$i++){
        $data = $redis->get('a.' . $i);
       if( $redis->exists('b.'.$data)){
           //存在 code
       }
       $num++;
       if(in_array(($Acount/$num),$chkary)){
           sleep(1); //防止卡死
       }
    }

    reply
    0
  • 漂亮男人

    漂亮男人2017-05-16 13:09:52

    You can write a script to cache the contents of the four texts into four Redis collections, and then find the intersection. This is very fast. I wonder if this is allowed?

    reply
    0
  • 给我你的怀抱

    给我你的怀抱2017-05-16 13:09:52

    The 500 error is that there is not enough memory. You can execute a few lines to release the useless memory

    reply
    0
  • Cancelreply