定时事件与php / MySQL [英] Timed events with php/MySQL

查看:110
本文介绍了定时事件与php / MySQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要一段时间才能修改表中的值。我现在的方法如下:

I need a way to modify a value in a table after a certain amount of time has passed. My current method is as follow:


  • 在表中插入等待期的结束时间

  • 用户加载请求更改值的页面,检查当前> =结束时间

  • 如果是,更改值并删除结束时间字段(如果不是) ,不做任何

这将是网站上的一个主要功能,因此效率是关键;考虑到这一点,你可能会看到我在做什么的问题。每次有人访问需要该信息的页面时,都会调用相同的代码块。

This is going to be a major feature on the site, and so efficiency is the key; with that in mind, you can probably see the problem with how I'm doing it. That same chunk of code is going to be called every time someone access a page that needs the information.

对于改进或更好的方法的任何建议都将非常感谢, php或perl。

Any suggestions for improvements or better methods would be greatly appreciated, preferably in php or perl.

回应cron工作答案:
谢谢,如果可能,我想做这样的事情,但主机限制是问题。由于这是应用程序的主要部分,因此不能限制。

In response to cron job answers: Thanks, and I'd like to do something like that if possible, but hosts limits are the problem. Since this is a major part of the app, it can't be limited.

推荐答案

为什么不用cron来更新这些信息?这样你就可以在每个页面上点击检查,实际上可以安排时间来满足应用的需求。

why not use a cron to update this information behind the scenes? that way you offload the checks on each page hit, and can actually schedule the timing to meet your app's requirements.

这篇关于定时事件与php / MySQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆