Hi
What is the best way of pre-populating the second level cache? Can this be configured from Hibernate?
Here is an example, let’s say an application has a persistent class called User, and there are 1 million instances in production. As memory is cheap, the server has enough memory to cache all users (e.g. several Gb). Also, start up time is not a problem (within reason).
In a standard cache configuration there will be at least 1 million select statements (e.g. for each user, access a User instance from the code, check in cache + miss, load from database, put instance into cache).
The approach I am thinking is to be able to configure the cache/Hibernate so that it loads all Users with a single “select * from user” statement at start up, and then puts all those users into the cache. This solution will be much faster and generate less network traffic than the 1 million smaller select statements, and this happens at start time rather than normal operation time.
Any ideas? Is this possible?
Many thanks
Eduard
|