bytes85
bytes85

Reputation: 3

daemon software to update mysql database in background

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

Upvotes: 0

Views: 691

Answers (2)

frow
frow

Reputation: 874

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.

Upvotes: 0

ypercubeᵀᴹ
ypercubeᵀᴹ

Reputation: 115510

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.

Upvotes: 2

Related Questions