Reputation: 8783
I'm building a newsletter application and I want to implement a feature that will allow users to program when their message will be delivered. For example to be able to deliver a message at 12:32 PM on 01/02/2013. I read about events in MySQL, but this doesn't solve my problem.
The only solution that comes to mind is to set up a cron script to run every minute and check if there's a message programmed. If it is, then deliver the message and perform any additional tasks.
Any other idea?
Upvotes: 1
Views: 251
Reputation: 5919
As an alternative to a cron job polling your mysql database every minute, you could try using a task queue like beanstalk which allows you to launch asynchronous jobs. It allows you to specify a delay before a task is run, so you could convert the time the user specifies that the job should be run to the relative delay. You could then provide an interface to the user to have control over the jobs that they scheduled, if they want to cancel them. Really, for this purpose, if there aren't many, many jobs that are going to be scheduled this way, and your mysql table is relatively small, it's probably simpler to go the mysql/cron route.
Upvotes: 0