开发者

php unlink continuously

开发者 https://www.devze.com 2023-02-11 09:04 出处:网络
I am experimenting with php unlink(), what I want to do is run a php script that deletes files created every few minutes after parsing them. I can do that with a cron or as continuously running the fi

I am experimenting with php unlink(), what I want to do is run a php script that deletes files created every few minutes after parsing them. I can do that with a cron or as continuously running the file that handles parse/delete on the background. What I want to ask is will deleting files every few minutes, cause problems to my web server or is there any performance downgrade when doing this or some othe开发者_StackOverflowr negative effect I can't think of?

Also how can I create a queue of files to process and dispose with php? Is that any different that what I described above?

Any help is greatly appreciated, I am a bit lost on this.


I think the approach would be based on some variables...

  1. Are you wanting to do this for a user-session?
  2. Are you wanting to do it strictly based on time?
  3. The images you are creating, are they stored or referenced globally?
  4. Are these images being used for any extended period of time, does that time change anything?

The easiest solution, in my opinion would be to create a cron job. If you can store the image and creation date (db or session), when your cron runs it can evaluate creation time vs script run-time and execute appropriately.

You have a lot of other options, but I think it comes down to the variables listed. Hope this helps.


Parsing the files will probably produce a higher load than deleting them afterwards. Without knowing more about what your parse processing and your server environment it will be impossible to say whether there will be any noticeable performance degradation.

I would create a MySQL table to hold a list of files to process. You can then add entries to the table from one script and remove them after parsing/deleting them.

0

精彩评论

暂无评论...
验证码 换一张
取 消