Deleting files and corresponding entries from database

后端 未结 5 753
情书的邮戳
情书的邮戳 2021-01-25 19:08

I have a web site which handles files management. User can upload file, add description, edit and delete. What are the best practices for that kind of scenario?

  1. <
5条回答
  •  礼貌的吻别
    2021-01-25 19:49

    There is often a garbage collection phase, and in fact your database has something similar called the "transaction log" which it can use to rewind or play forward a transaction.

    In the case of your file delete you will have a clean-up process that runs periodically (perhaps manually in the event of a crash, or automatically every so often) that compares what is on the disk with what is in the database and makes an appropriate correction.

    In order for any operation to be "atomic" there must be a method of cleaning up in the event of a crash. The key is finding a method that cleans up consistently such that a failure at any point within the "atomic" operation doesn't leave the system unrecoverable.

提交回复
热议问题