SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Mar 2004
    Location
    Earth
    Posts
    406
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do you sequence tasks in PHP?

    Let's say for example that I'm querying the Twitter API for tweets on a particular topic, which is initiated by a user search. What I then want to do is query the API again, say every 10 minutes for the next hour, and save any new tweets that have come in on the same subject.

    Once the user has initiated the process by running the first search, what are the mechanics for implementing that sequence of repeated searches? What do you do to make that happen, without any further activity from the user?

  2. #2
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    8,900
    Mentioned
    138 Post(s)
    Tagged
    2 Thread(s)
    That sounds like an excellent job for beanstalkd. Here is a nice intro to it: http://abulman.co.uk/presentations/B...kd-2010-05-06/

    Basically what you want to do when a user searches something is to add 6 messages to the queue, one in 10 minutes, the next in 20, then 30, 40, 50 and 60. In the background you have a PHP script that waits for messages back from beanstalkd and can than do anything you want it to (in your case, you wire it to a script that searches the twitter API).

    There are other queueing systems you can use, but beanstalkd is nice and easy to learn and should should suffice for your purposes
    Rémon - Hosting Advisor

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  3. #3
    SitePoint Guru
    Join Date
    Mar 2004
    Location
    Earth
    Posts
    406
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That does look like it might do the trick, yes -- thanks for the link.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •