php连续取消链接

发布于 2024-10-17 14:06:08 字数 257 浏览 2 评论 0原文

我正在试验 php unlink(),我想做的是运行一个 php 脚本,该脚本在解析文件后每隔几分钟删除创建的文件。我可以使用 cron 或连续运行在后台处理解析/删除的文件来做到这一点。我想问的是,每隔几分钟就会删除文件,给我的网络服务器带来问题,或者在执行此操作时是否会导致性能下降或我无法想到的其他负面影响?

另外,我如何创建一个文件队列来使用 php 进行处理和处理?这和我上面描述的有什么不同吗?

非常感谢任何帮助,我对此有点迷失。

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 other 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

无法言说的痛 2024-10-24 14:06:08

我认为该方法将基于一些变量...

  1. 您想对用户会话执行此操作吗?
  2. 你想严格按照时间来做吗?
  3. 您正在创建的图像是否在全球范围内存储或引用?
  4. 这些图像是否被使用了很长一段时间,这段时间会改变什么吗?

我认为最简单的解决方案是创建一个 cron 作业。如果您可以存储图像和创建日期(数据库或会话),那么当您的 cron 运行时,它可以评估创建时间与脚本运行时间并适当执行。

您还有很多其他选择,但我认为这取决于列出的变量。希望这有帮助。

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.

把回忆走一遍 2024-10-24 14:06:08

解析文件可能会比事后删除它们产生更高的负载。如果不了解更多关于解析处理和服务器环境的信息,就不可能说是否会出现任何明显的性能下降。

我将创建一个 MySQL 表来保存要处理的文件列表。然后,您可以从一个脚本向表中添加条目,并在解析/删除它们后将其删除。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文