How can I set the value of a column in mysql to either null or empty 1 hour after the value is set?
Asked
Active
Viewed 73 times
0
-
This sort of thing might typically be handled by an application sitting on top of a MySQL instance, rather than being handled directly from MySQL. Can you give more context to your question? – Tim Biegeleisen Jun 23 '17 at 06:54
-
@TimBiegeleisen It's for a login token. User log's in, token is generated for application, after an hour, token expires but is still in mysql so the application stops working. – Carter Roeser Jun 23 '17 at 06:57
-
See this post https://stackoverflow.com/questions/2348863/how-to-run-a-stored-procedure-in-sql-server-every-hour – Angelo Jun 23 '17 at 06:58
-
Why can't you just compare the expiry date against the current time? By the way, if you're using Java, there is a truly awesome new thing called stateless session tokens. They live outside the database and you never even have to hit your database when checking access tokens. – Tim Biegeleisen Jun 23 '17 at 06:59
-
@Angelo this is MySQL, not Microsoft – Carter Roeser Jun 23 '17 at 06:59
-
@TimBiegeleisen Mainly server resources because it would be referencing the db very often, and no, this is not in Java. – Carter Roeser Jun 23 '17 at 07:10
-
@CarterRoeser Look into database caching (e.g. Memcache). You always have to check against the database, but that doesn't necessarily mean always hitting it. – Tim Biegeleisen Jun 23 '17 at 07:11