CodeIgniter Forums
mulithreading - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: mulithreading (/thread-1913.html)



mulithreading - El Forum - 07-04-2007

[eluser]unosoft[/eluser]
I am wondering if there was a way that we can load the view and then in the background do some other database inserts.

For example:
$this->load->view(’vquick’);
$this->MTag->insertRecords(); --> I would like this insert to happen in a separate thread so that user does not have to wait for the insert to complete.

Kumar

p.s: Sorry...this is not a cross post. I posted this message in the Lounge forum accidentally earlier.


mulithreading - El Forum - 07-04-2007

[eluser]esra[/eluser]
I believe that PHP has an optional or third-party module supporting apartment threading. Fairly sure about this but not positive. The problem of course is that the module needs to be installed on any server where your application is installed.


mulithreading - El Forum - 07-04-2007

[eluser]champs[/eluser]
PHP multithreading looks very experimental and not-recently-updated... as in two or three years ago.

Take a peek into CI's hooks feature -- it looks like post_system would work for this.


mulithreading - El Forum - 07-04-2007

[eluser]Nanodeath[/eluser]
Could also use INSERT DELAYED if you're using MySQL.

Quote:When a client uses INSERT DELAYED, it gets an okay from the server at once, and the row is queued to be inserted when the table is not in use by any other thread.

Another major benefit of using INSERT DELAYED is that inserts from many clients are bundled together and written in one block. This is much faster than performing many separate inserts.



mulithreading - El Forum - 01-30-2009

[eluser]bd3521[/eluser]
Is there anyway to implement $this->db->insert_delayed in CI? As long the table is MyISAM or Archive it should work by switching from INSERT to INSERT DELAYED