• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

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->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.


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

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.

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.

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.

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

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.