How do I implement a Timer on this MVC setup?
Using Java Spring, I have a page which pulls a random auction listing from its database, and refreshes this action every time the user refreshes the browser.
Instead, I want to make it show the same randomly chosen auction for all users, switching to a new random one every hour. ("Here is this hour's featured auction!")
Here is how my current flow works:
- Data.xml pulls in random auction from db.
- DAO created from sql import
- public List created from DAO, does a few special things here with the data.
- List from that List created in page controller, added to a MVC map for use on front end.
Kind of running out of time here, so I'm just going to create a kind of stop valve on this, so it only gets the data once every hour instead of on request.
N开发者_如何学运维ot asking for code here, but a strategy. Should I go with a CronTrigger? And where should the job be?
(Thanks :) )
Sounds like new Spring caching support might be helpful: set cache time to live to 1 hour with condition (or clear it manually with any scheduler).
精彩评论