Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #14180 > unrolled thread
| Started by | Tuấn Dương Trần <duongtt84@gmail.com> |
|---|---|
| First post | 2014-08-19 06:48 -0700 |
| Last post | 2014-08-21 03:16 -0600 |
| Articles | 7 — 4 participants |
Back to article view | Back to comp.lang.php
Asynchronous Function Call in PHP Tuấn Dương Trần <duongtt84@gmail.com> - 2014-08-19 06:48 -0700
Re: Asynchronous Function Call in PHP Jerry Stuckle <jstucklex@attglobal.net> - 2014-08-19 11:45 -0400
Re: Asynchronous Function Call in PHP Tuấn Dương Trần <duongtt84@gmail.com> - 2014-08-20 02:38 -0700
Re: Asynchronous Function Call in PHP Jerry Stuckle <jstucklex@attglobal.net> - 2014-08-20 06:25 -0400
Re: Asynchronous Function Call in PHP crankypuss <crankypuss@nomail.invalid> - 2014-08-21 03:18 -0600
Re: Asynchronous Function Call in PHP "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-08-21 16:37 +0200
Re: Asynchronous Function Call in PHP crankypuss <crankypuss@nomail.invalid> - 2014-08-21 03:16 -0600
| From | Tuấn Dương Trần <duongtt84@gmail.com> |
|---|---|
| Date | 2014-08-19 06:48 -0700 |
| Subject | Asynchronous Function Call in PHP |
| Message-ID | <0ca6166b-e6cd-445e-be59-bee46d8f0070@googlegroups.com> |
Hi every body, I'm building a website using Yii2, Redis, mysql. I need to write a function marking the songs, scores are stored in Redis and mysql. Scoring function using ajax to call the controler. I want this function to run in sequence as follows: The number is stored in Redis and returns immediately, then use a background thread to save the results into mysql. How i can do? Thanks.
[toc] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2014-08-19 11:45 -0400 |
| Message-ID | <lsvreh$ia9$2@dont-email.me> |
| In reply to | #14180 |
On 8/19/2014 9:48 AM, Tuấn Dương Trần wrote: > Hi every body, > I'm building a website using Yii2, Redis, mysql. I need to write a function marking the songs, scores are stored in Redis and mysql. Scoring function using ajax to call the controler. I want this function to run in sequence as follows: The number is stored in Redis and returns immediately, then use a background thread to save the results into mysql. How i can do? > > Thanks. > You would have to start another script to update the MySQL database. This can be done with the exec() call, if it is allowed on your system (many shared hosts do not allow it). However, it shouldn't take long to update your database (i.e. typically milliseconds). Why do you think you need a background thread to do it? -- ================== Remove the "x" from my email address Jerry Stuckle jstucklex@attglobal.net ==================
[toc] | [prev] | [next] | [standalone]
| From | Tuấn Dương Trần <duongtt84@gmail.com> |
|---|---|
| Date | 2014-08-20 02:38 -0700 |
| Message-ID | <bab60a92-5f22-48ec-8781-917b83364d47@googlegroups.com> |
| In reply to | #14183 |
Vào 22:45:21 UTC+7 Thứ ba, ngày 19 tháng tám năm 2014, Jerry Stuckle đã viết: > On 8/19/2014 9:48 AM, Tuấn Dương Trần wrote: > > > Hi every body, > > > I'm building a website using Yii2, Redis, mysql. I need to write a function marking the songs, scores are stored in Redis and mysql. Scoring function using ajax to call the controler. I want this function to run in sequence as follows: The number is stored in Redis and returns immediately, then use a background thread to save the results into mysql. How i can do? > > > > > > Thanks. > > > > > > > You would have to start another script to update the MySQL database. > > This can be done with the exec() call, if it is allowed on your system > > (many shared hosts do not allow it). > > > > However, it shouldn't take long to update your database (i.e. typically > > milliseconds). Why do you think you need a background thread to do it? > > > > -- > > ================== > > Remove the "x" from my email address > > Jerry Stuckle > > jstucklex@attglobal.net > > ================== Thanks Jerry Stuckle, Function points that I mentioned above is a small part of the website that I am building. My websites like social networks, can automatically record user actions, keyword searches, favorite topics. I need a background process to calculate points based on that information, then write to the db. I'm looking to understand pthreads, but i don't know it can do?
[toc] | [prev] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2014-08-20 06:25 -0400 |
| Message-ID | <lt1t3a$3jj$1@dont-email.me> |
| In reply to | #14184 |
On 8/20/2014 5:38 AM, Tuấn Dương Trần wrote: > Vào 22:45:21 UTC+7 Thứ ba, ngày 19 tháng tám năm 2014, Jerry Stuckle đã viết: >> On 8/19/2014 9:48 AM, Tuấn Dương Trần wrote: >> >>> Hi every body, >> >>> I'm building a website using Yii2, Redis, mysql. I need to write a function marking the songs, scores are stored in Redis and mysql. Scoring function using ajax to call the controler. I want this function to run in sequence as follows: The number is stored in Redis and returns immediately, then use a background thread to save the results into mysql. How i can do? >> >>> >> >>> Thanks. >> >>> >> You would have to start another script to update the MySQL database. >> >> This can be done with the exec() call, if it is allowed on your system >> >> (many shared hosts do not allow it). >> >> However, it shouldn't take long to update your database (i.e. typically >> >> milliseconds). Why do you think you need a background thread to do it? >> >> > > Thanks Jerry Stuckle, > > Function points that I mentioned above is a small part of the website that I am building. My websites like social networks, can automatically record user actions, keyword searches, favorite topics. I need a background process to calculate points based on that information, then write to the db. I'm looking to understand pthreads, but i don't know it can do? > I generally don't recommend the use of pthreads for the same reason that I generally don't recommend the use of exec() and the like. pthreads is a PECL class which requires special installation. You will find very few shared hosts who will install it for you; you will almost be assured you will have to run your own server. But once again - does it really take that long for what you want to do? Have you tried it? Or are you prematurely optimizing? I'm not sure what you need to "calculate" - but things like logging user information is still quite fast, and is done regularly by many CMS's, without the use of multi-threading. -- ================== Remove the "x" from my email address Jerry Stuckle jstucklex@attglobal.net ==================
[toc] | [prev] | [next] | [standalone]
| From | crankypuss <crankypuss@nomail.invalid> |
|---|---|
| Date | 2014-08-21 03:18 -0600 |
| Message-ID | <lt4dgo$p3$2@dont-email.me> |
| In reply to | #14185 |
On 08/20/2014 04:25 AM, Jerry Stuckle wrote: > I generally don't recommend the use of pthreads for the same reason that > I generally don't recommend the use of exec() and the like. pthreads is > a PECL class which requires special installation. You will find very > few shared hosts who will install it for you; you will almost be assured > you will have to run your own server. I've heard that PHP garbage collection is not up to the task of long-running processes; never had issues with that myself but it wouldn't surprise me one way or the other. There's also cron if one has the necessary access to set it up.
[toc] | [prev] | [next] | [standalone]
| From | "Christoph M. Becker" <cmbecker69@arcor.de> |
|---|---|
| Date | 2014-08-21 16:37 +0200 |
| Message-ID | <lt5074$ve7$1@solani.org> |
| In reply to | #14187 |
crankypuss wrote: > I've heard that PHP garbage collection is not up to the task of > long-running processes; never had issues with that myself but it > wouldn't surprise me one way or the other. PHP's garbage collector was completely reworked for PHP 5.3, and since than it takes cyclic references into account and frees them up appropriately. In older versions such cyclic references will cause memory leaks. See <http://php.net/manual/en/features.gc.collecting-cycles.php>. -- Christoph M. Becker
[toc] | [prev] | [next] | [standalone]
| From | crankypuss <crankypuss@nomail.invalid> |
|---|---|
| Date | 2014-08-21 03:16 -0600 |
| Message-ID | <lt4dbj$p3$1@dont-email.me> |
| In reply to | #14184 |
On 08/20/2014 03:38 AM, Tuấn Dương Trần wrote: > Function points that I mentioned above is a small part of the website that I am building. > My websites like social networks, can automatically record user actions, keyword searches, > favorite topics. I need a background process to calculate points based on that information, > then write to the db. I'm looking to understand pthreads, but i don't know it can do? Haven't had a website for years now, but what I used to do was a cheap-background process... I ran everything through "index.php" then after the page had been sent I'd call a general background routine. I've forgotten the exact details of how to make sure the page had been fully sent but if you want to do it that way I'm sure somebody that stays on top of the website aspect of PHP can help, I'm mostly using PHP for command-line functions and local applications these days.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.php
csiph-web