简体   繁体   中英

Storing large amounts of updated data, in a session?

So I have an application which allows a user to type sentences/paragraphs into a textbox. In the background a timer is running. Every 5 seconds the value of the textbox is to be copied and stored into the database or in an xml file (via ajax). I thought it would be quite unsafe if I updated the db/xml file ever 5 seconds.

My thinking is - when the user presses stop on the timer - it will then save all the data into the database/xml file. Instead of every 5 seconds it gets updated.

However I still need to store the values at each interval. Should I go about using at session with an array inside? How much can a session take. It would look like: $_SESSION['content'][] = "Massive long string text!";

Example: User is typing for 10 minutes straight and the body of the text is saved into the session array every 5 seconds. Is this too stressfull? Each paragraph might be 1000 characters in length at each interval.

What would you suggest?

Try using a hidden element (eg textarea), then a javascript function fill the element every 5 seconds from user_textbox value. To reduce server load, you can store the contents of the hidden element to the database when user_textbox blur.

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