question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pre-populate Cache

See original GitHub issue

Original 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:closed
  • Created 9 years ago
  • Comments:23

github_iconTop GitHub Comments

8reactions
Normalcommented, Mar 15, 2018

but what if I need the data be populated repeatedly on eviction time is over? PutAll doesn’t handle that. Isn’t it?

1reaction
gissuebotcommented, Oct 31, 2014

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found