简体   繁体   中英

Storing file edits or user actions in mysql

I'm working on an application that allows users to edit documents (spreadsheets and other docs) live.

When editing the files, a keyup function is triggered with AJAX which auto-sends a post request to save/update the file.

What I'd like to do, is add a notifications or someway of registering/logging that the user has updated the file. That could then get put into some-sort of a feed.

The problem is, that because there are a so many AJAX requests it would be impractical to log the edit based on AJAX save requests.

What would be a good structure to handle this?

I was thinking of using some sort of time-stamping method, and only log an edits if the previous time-stamp is out of a certain range (like 15mins or something).

Does anyone have any experience with this kind of thing? I'm really not sure what the best solution would be. I'm Trying to come up with few ideas to see what a suitable solution would be to this (in terms of table(s) structure and general direction). Perhaps someone here can help.

If you have so many AJAX request, is going to be quite hard if you have to read on the server every time that you send an AJAX request if there is a log row for your user in the period of time you want, as you have to make a read action over a time field, and then a write action, that is, you'll be all the time reading a table that will have millions of rows. That can hit your performance and the speed of response, and load unnecessarily your database server.

I think that an improvement would be send a var as "log this" signal with your AJAX request. And your table won't have to check if there is or not a previous value, it will only insert your log request if the signal is ON. You only have to keep in the client side a time counter which will set the "log this" signal according to the time, vars, length of edit...

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