开发者

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:

  1. Data.xml pulls in random auction from db.
  2. DAO created from sql import
  3. public List created from DAO, does a few special things here with the data.
  4. 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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜