Prevent two users from editing the same data

邮差的信 提交于 2019-12-01 07:37:39

Does editing an article always take less than 100 seconds ?

Yeah, that's great and should work fine.

In addition, I'd add the possibility for user B to break the lock - if that's at all wanted!

That is, the possibility to replace A's lock by B's. This way, you could avoid the time restraint, and they would see 'Hey, this is being edited by A, and this lock is XXX seconds/minutes old. Do you want to break this lock?'.

With nice users (i.e. no malicious admins), this approach may be better than having just 100 seconds to edit something - sometimes you just need more time.

Sounds like it will work fine. If you want to denormalize this and remove the extra Events table, just add a UserId and Timestamp field to the Articles table, as that is all you really need.

You can easily check if the UserId doesn't match and if the Timestamp is less than 100 seconds old, then show the message.

This way, you won't have to do any deletions on a separate table.

I'd just add that you could have an AJAX query fire every minute or so if something has been done on the page to update the timestamp.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!