Home > Back-end >  Php, multiple file operations (delete, create) in one go? Like transactions
Php, multiple file operations (delete, create) in one go? Like transactions

Time:12-10

let's say I have a long generating function:

  • delete all generated files
  • generate cached JSON-s (can be 10-15 files).

As the 2nd step takes 5 minutes, it's easy to overview that if users trying to access the related content, they will see zero, or "missing" content. The best way is like transaction: getting the full result in the fragment of seconds. Is there any way to achieve this in Php? I couldn't find a way so far.

CodePudding user response:

What about to generate the cache in another folder ? When it's done you just have to change the path to the cache, it will take no time. And after that you can delete the old cache. You can swap like that between two folders.

  • Related