开发者

daemon software to update mysql database in background

开发者 https://www.devze.com 2023-03-30 06:33 出处:网络
I\'m writing a realtime wep application, something similar to auction site. The problem is that I need a daemon script, preferrably php, that runs in background and constantly launches queries to mysq

I'm writing a realtime wep application, something similar to auction site. The problem is that I need a daemon script, preferrably php, that runs in background and constantly launches queries to mysql db and basing on some of criterias (time and conditions from resultsets) updates other tables. Performance of the daemon is crucial. Sample use case: we have a deal that is going to expire in 2:37 minutes. Even if nob开发者_运维问答ody is watching/bidding it we need to expire it exactly in 2:37 since the time it started.

Can anybody advise a programming technology/software that performs this kind of task the best?

Thanks in advance

UPDATED: need to perform a query when a deal expires, no matter if it has ever been accessed by a user or not.


Why do you need to fire queries at time intervals? Can't you just change how your frontend works?

For example, in the "Deals" page, just show only deals that haven't expired - simplified example:

SELECT * FROM Deal WHERE NOW() <= DateTimeToExpire

Accordingly for the "Orders" page, a deal can become a placed order only if time hasn't expired yet.


Does your daemon need to trigger actions instantaneously? If you need a table containing the expired state as a column you could just compute the expire value on the fly or define a view? You could then use a daemon/cron job querying the view every 10 minutes or so if you have to send out emails or do some cleanup work etc.

0

精彩评论

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