Pre-populate Cache
See original GitHub issueOriginal issue created by richarddowsett on 2011-10-27 at 12:14 PM
Pre-populating a cache is a common use case for loading static data from a database. This would also be specifically useful where lazy loading is not ideal. Please see http://stackoverflow.com/questions/7915016/pre-load-values-for-a-guava-cache for a specific case where this would be useful.
It would be ideal to create an interface that can pre-load all static data from the database and add it to the Cache at start-up, such as:
CacheBuilder.newBuilder().populate(new CachePopulator<String, Element>(){
@Override
public Map<String, Element> populate() throws Exception {
return getAllElements();
}
}).build(new CacheLoader<String, Element>(){
@Override
public Element load(String key) throws Exception {
return getElement(key);
}
});
Issue Analytics
- State:
- Created 9 years ago
- Comments:23
Top Results From Across the Web
How to pre-populate data in cache with spring and ehcache?
I have introduced Ehcache in my web application. It is working file when I try to populate the cache after server startup.
Read more >20 Pre-Loading a Cache
1 Bulk Writing to a Cache. A common scenario when using Coherence is to pre-populate a cache before the application uses it. A...
Read more >Pre-populate the cache
The pre-population feature allows you to warm the Exinda SMB, Edge, and WANWide Area Network memory caches in advance of end users accessing...
Read more >Managing cache prepopulation - IBM
The prepopulation feature moves files into the cache in batch mode so that they are already present in the cache when they are...
Read more >volume flexcache prepopulate start - Product documentation
The FlexCache prepopulate job fails when the directories listed with the -path-list have one or more non-existing paths. Parameters. -cache- ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
but what if I need the data be populated repeatedly on eviction time is over? PutAll doesn’t handle that. Isn’t it?
Original comment posted by richarddowsett on 2011-10-28 at 12:07 PM
I’m assuming this would be the interface for the new feature (or something similar): Cache.getAll(List<K> keys).
As Raymond has pointed out, this would result in keys.size() calls to the database where my solution would allow you to get all values in a single DAO call. This would surely be a better solution where the cache needs to be pre-populated with a large number of elements.