When Jeff made Stackoverflow, he had a similiar issue.
His solution was to use the cache expiration. You'd put something in the cache and then when it expires an event is fired in a non-user facing thread. In the event handler for the expiration, you stick some code in to re-add the item to the cache and do whatever housekeeping work needs to be done for your application
Using this technique, your subquestions are easily answered:
- You check the item is still in
cache.
- If the item is not in
cache, re-add it.
- Remove the
cache item from the cache.
- Add
the item back to the cache.
You could make a small management page to configure these options.
This gives you a nice way to roughly time housekeeping processes in your web-application. It doesn't require a seperate Windows Service, which is a big win.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…