Layer 2 sleeping cache and one to one relationship

I have an object that I would like to cache in the second level cache, but it is often updated (using hibernate), and this makes it a weak candidate for the second level cache.

However, only 2 fields change frequently, while other columns are read frequently and are fairly static.

Is it possible to transfer these frequently changing fields to another table and create a one-to-one relationship with this new object? That way I could cache the original object, now that the columns are removed, and there is no need to cache a new object. Or could any benefit be lost due to frequent calls?

I know that I have to do my own analysis to make sure, but I wanted to check if I'm really in the right / normal way.

+3
source share
1 answer

If you use the lazy boot connection between your main object and the outer part, and you don't need the outer part very often, if you could help.

If you need the external part very often, this will not help, because you always need to access the database in any way. - One of the exceptions would be: if your main object is very large, and the connection to the database is very slow.

But at least you're right: you need to test it yourself.

0
source

Source: https://habr.com/ru/post/1791420/


All Articles