I have hundreds of records, all with an expiry datetime column. Something like this:
Name Expires Status
-----------+---------------------+--------+
Apple1 2017-05-05 10:10:15 Live
Apple2 2017-06-01 18:15:03 Live
Apple3 2017-01-01 23:59:59 Dead
Apple4 2017-01-30 23:00:01 Draft
Apple5 2017-01-30 23:00:01 Queued
I want to change the status of any record that is Live
after the expiry datetime has elapsed.
So far I have thought about these possible solutions:
- Set up a SQL Server job to run some update script every second
- Do it using the application server (ColdFusion 2016) on every page request. So everytime a page is requested it will run this update script in the application's
onRequestStart()
method.
Both seem a bit "Web 1.0" and possibly very costly. I guess I'm trying to do what Facebook does when it publishes scheduled posts as soon as correct time arrives but can't work out to do it efficently.
Could anyone please suggest what would be a good way to achieve this?