I'm planning on caching some information using ehcache. Normally, I would follow the pattern:
if data in cache
return from cache
else
lookup from source
put into cache
return data
But for this data, I'd like it to always be in memory. I'd prefer to do:
- Populate cache while appserver starts up (I'm using JBoss)
- Have a "process/thread/something" that periodically updates the cache
My first thought is to define a servlet with a ServletContextListener
that does the initial load and then starts a thread to do the updates.
Is there some better way to do this?