How to implement background / asynchronous write caching in PHP?

I have a specific PHP page that, for various reasons, should save ~ 200 fields in the database. These are 200 separate insert and / or update statements. Now the obvious thing is to reduce this number, but, as I said, for reasons that I will not go into, I can not do this.

I did not expect this problem. The selections seem quite effective in MySQL, but there are no inserts / updates (this update takes about 15-20 seconds, which is naturally unacceptable). I wrote Java / Oracle systems that can happily make thousands of attachments / updates at the same time (in both cases, local databases, MySQL 5 and OracleXE work).

Now in something like Java or .Net, I could easily do one of the following:

  • Writing data to the memory cache entry (i.e., he will know how to save the database and can do this asynchronously);
  • Write data to the memory cache and use PaaS (Persistence as a Service), i.e. the listener cache will save the fields; or
  • Just start the background process which can be saved.

The minimum solution is to have a cache that I can just update, which will separately start and update the database in due time (that is, it will be returned immediately after updating the cache in memory). This can be either a global cache or a session cache (although the global shared cache is handled differently).

Any other solutions to this problem?

+5
source share
10

200 , . , - -.

, . , , , MySQL , .

, , . .

, , - - . , ( ), .

, , .

+1

, ( mysql:)), - JMS- STOMP PHP . ActiveMQ STOMP. StompConnect , - STOMP JMS (OpenMQ, JBossMQ ..).

+2

mysql_query ('INSERT INTO tableName VALUES (...), (...), (...), (...)')

. insert. . 1. csv ( ) txt , , (, FileOutputStream java). 2.

LOAD DATA INFILE 'data.txt' INTO TABLE table2 , '\ t';

3, ,

http://dev.mysql.com/doc/refman/5.1/en/load-data.html

+2

(, memcached), beanstalkd.

+1

, . , , , . , , / , , UPDATE INSERT.

, , MYISAM ( ), UPDATE. INNODB. INNODB SELECT -queries, INSERT UPDATE, , , .

+1

, INSERT-ONLY ( ), MyISAM.

, , /.

, " ".

+1

SQL - . ? mysql , ? , .

0

,

mysql_query('INSERT INTO tableName VALUES(...)');
mysql_query('INSERT INTO tableName VALUES(...)');
mysql_query('INSERT INTO tableName VALUES(...)');
mysql_query('INSERT INTO tableName VALUES(...)');
mysql_query('INSERT INTO tableName VALUES(...)');

mysql_query('INSERT INTO tableName VALUES(...),(...),(...),(...)');

, , PHP , ..

0

:

mysql_query('start transaction');
mysql_query('INSERT INTO tableName VALUES(...)');
mysql_query('INSERT INTO tableName VALUES(...)');
mysql_query('INSERT INTO tableName VALUES(...)');
mysql_query('INSERT INTO tableName VALUES(...)');
mysql_query('INSERT INTO tableName VALUES(...)'); 
mysql_query('commit;')
0

All Articles