Twitter competition ~ saving tweets (PHP & MySQL)

后端 未结 4 2274
一整个雨季
一整个雨季 2021-02-09 16:27

I am creating an application to help our team manage a twitter competition. So far I\'ve managed to interact with the API fine, and return a set of tweets that I need.

I

4条回答
  •  逝去的感伤
    2021-02-09 16:29

    I think running a cron every X minutes and basing it off of the tweets creation date may work. You can query your database to find the last date/time of the last recorded tweet, then only run selects if there are matching times to prevent duplicates. Then, when you do your inserts into the database, use one or two insert statements containing all the entries you want to record to keep performance up.

    INSERT INTO `tweets` (id, date, ...) VALUES (..., ..., ...), (..., ..., ...), ...;
    

    This doesn't seem too intensive...also depends on the number of tweets you expect to record though. Also make sure to index the table properly.

提交回复
热议问题