Reputation: 1327
I'm using Play Framework's Cache API to store the immutable results of expensive web requests to speed up the user's experience. It is set to expire after an hour. At which point, the next user to request the results will have to wait 30 seconds+, which is obviously not ideal.
Is there a way to make the web request in the background, once the cache has expired? So that rather than the user having to wait for a long time, the server could make the request in the background and cache the new results? Perhaps even a minute before it expires?
Upvotes: 0
Views: 65
Reputation: 3887
Use Akka Scheduler
.
system.scheduler.schedule(0 milliseconds,
60 minutes)(expensiveFunction())
Upvotes: 2