Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/15/2021 in all areas

  1. It sounds like you might just need to re-consider your design. If it's the client that's interested in whatever this change is, the typical solution to this is to just have the client make a request periodically. One name for this is Ajax Polling. You make an Ajax request to your change detection script. The script will check for the change in a loop and return when a change is detected. You could wait 30 minutes, but it's more typical to wait 30-sec to a minute then return a "No changes" response. This way your web-server's available threads don't get used up waiting. If the change detection is only relevant to the server and not the client, then either cron or a service would be the more appropriate implementation. This sounds like something that's more typically done with a cron job. Your database row would contain a timestamp of when it was created or when it needs to be destroyed. You then schedule a script via cron (or some other scheduler) that runs every minute and deletes any rows that have expired. Similar to above, you don't really want to make a request to your server that just waits for 10 minutes as it'll tie up resources and it's particularly reliable anyway (might timeout / get killed). In regard to your original post, multi-tasking is generally handled by using multiple requests rather than one request that executes sub-scripts. It's possible to execute sub-scripts concurrently like you want, but it's somewhat complicated to do. Sending separate requests is much easier. Browsers do have a limit to how many concurrent requests they will make that you need to keep in mind though.
    1 point
  2. You mean are most questions we get here about Javascript? No, it's mostly PHP, but it's mostly PHP in a web context. As in PHP is running on a website and people are visiting it in their browser. Which means Javascript is an option. But sometimes there are non-web PHP questions. I don't know which one of those this thread is yet... If you want to run something every X minutes then the standard answer is to use cron: every *nix server has it, it runs in the "background", meaning it's not driven by or reliant upon users taking specific actions (such as "keeping the browser open so something can do AJAX requests"), and you can still do just about anything you want with PHP. For the 30 minutes one, you make a script that runs whatever database queries it needs. I don't know what it's supposed to do if the value changes? Then you tell the server (exact steps vary) that you want to run some command-line program (ie, PHP with the path to your script) every 30 minutes. For the 10 minutes one, you make a script that runs whatever database queries it needs. Then you tell the server you want to run a second program (also PHP) every 10 minutes.
    1 point
This leaderboard is set to New York/GMT-04:00
  • Newsletter

    Want to keep up to date with all our latest news and information?
    Sign Up
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.