简体   繁体   中英

Create temporary rows in mysql

Well, I want to do a Flash AS3 Chat.

When the user send a message, the message will be created as a row in mysql with PHP, but if it be so, the mysql server will be very busy, then the row must be temporary.

Someone can help me? ^^' Thanks and sorry for my bad english!

Temporary rows will not solve the problem with your MySQL server being too busy. MySQL can handle many (eg tens of thousands) transactions per second with a pretty normal setup. This article discusses quite a few of the parameters you might be interested in. So, that said, unless you have a TON of traffic on your chat system (and, I mean TONS and TONS) you will probably be ok just using MySQL, saving your rows, fetching your needed rows, and maybe writing a script to purge old rows after a certain date/time. Hope this helps!

If you're on a shared hosting platform, you can make a cron that matches the time. For example;

$db->query("DELETE FROM `messages` WHERE `message_posted` < DATE_ADD(NOW(), INTERVAL 2 HOUR)")

This will delete all the rows with a time two hours more than the current time.

Change the interval for your preference.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM