php连续取消链接
我正在试验 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为该方法将基于一些变量...
我认为最简单的解决方案是创建一个 cron 作业。如果您可以存储图像和创建日期(数据库或会话),那么当您的 cron 运行时,它可以评估创建时间与脚本运行时间并适当执行。
您还有很多其他选择,但我认为这取决于列出的变量。希望这有帮助。
I think the approach would be based on some variables...
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.
解析文件可能会比事后删除它们产生更高的负载。如果不了解更多关于解析处理和服务器环境的信息,就不可能说是否会出现任何明显的性能下降。
我将创建一个 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.