dongsuo9982 2011-08-25 01:24
浏览 73
已采纳

使计时器在过期记录上运行代码

I am developing a web application (PHP/MySQL), in which I need to implement timers (record id expires at expiration_date), where expiration involves the record's state being updated and arbitrary code being executed as required.

I basically need a BPMN Timer event.

Options I have considered, none of which I am thrilled with:

  • Cronjob calling a function in the application that just queries for and updates expired records.
  • At a commonly called point in the code, call this function at a fixed interval.

How is this commonly done in PHP applications?

  • 写回答

3条回答 默认 最新

  • doubian0284 2011-08-25 17:46
    关注

    I would also choose the cronjob option.

    I would also, however, have logic in my app that knows how to deal (or ignore) expired records. Services like cron can break, so it's nice to NOT have to rely upon it.

    Unfortunately, DBMSs don't give us quite this sort of flexibility, and you won't want to go off and do database maintenance in the event you come across one of these "expired" records.

    You're best excluding them through queries, the use of views, or simple application logic.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突