php - Recursive directory delete while creating new files -
so want create script delete folder , it's content, while doing there may created new files. best way this?
some illustration - have "cache" folder , want delete whole cache, while doing there more files created in cache folder , it's never empty not deleted.
move directory out of place (to /tmp
example). delete it. moves atomic, , quick (since it's pointer alter on filesystem , doesn't involve heavy disk i/o regardless of what's in folder).
for best resilience against type of issue, should create directory construction this:
/var/www/website/ releases/ 1111/ 1112/ 1113/ current_release/
let's website in /var/www/website/releases/1113/
. apache should setup documentroot
of /var/www/website/current_release/
symlinked /var/www/website/releases/1113
when need clear cache, should deploy new release, such /var/www/website/releases/1114
. when ti deployed, , has empty cache directory, flip symlink on /var/www/website/current_release/
new releases directory.
apache serve files out of new directory empty cache folder.
this atomic way accomplish things this, other taking server offline (which isn't alternative trivial clearing cache).
this sort of enterprise-level solution problem, carries added benefit of allowing roll production server (just switch symlink previous version). may seem over-engineering if you're concerned issue, right way.
php file caching recursion directory
No comments:
Post a Comment