I have a requirement where we are loading static data from a database for use in a Java application. Any caching mechanism should have the following functionality:
In the short-term I would just use Cache.asMap().putAll(Map<K, V>)
.
Once Guava 11.0 is released you can use Cache.getAll(Iterable<K>), which will issue a single bulk request for all absent elements.
I'd load all static data from the DB, and store it in the Cache using cache.asMap().put(key, value)
([Guava 10.0.1 allows write operations on the Cache.asMap() view][1]).
Of course, this static data might get evicted, if your cache is configured to evict entries...
The CachePopulator idea is interesting.