P
P
programmerjava2015-08-03 18:21:29
Java
programmerjava, 2015-08-03 18:21:29

Hibernate cache lvl2 vs Redis?

Dear colleagues!! Greetings to all who used this SUDB and Hibernate\JPA.
I have a question regarding the effectiveness of second-level cache for ORM versus manually caching data in Redis. I do not quite understand how ORM caches requests at the second level. Therefore, I want to ask. AS ? Most frequent? Is it possible to customize this cache? I would be grateful for all the tips and tricks :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Smirnov, 2015-08-13
@bobzer

In many cases, the answer to the question "what's the best way to cache" is "no way". Do you have specific data on the load testing of your application, in which you can clearly see which part of the System consumes which resources? If not, then google the phrase "premature optimization".
If you had a really serious, highly loaded application, then you would not ask such questions here, but you yourself would write articles on such topics.
Because A specific question is asked, so I'll answer anyway. Any more or less developed DBMS is perfectly able to cache everything that is needed and, in the general case, copes with this better than any caches. If you clearly see that it can no longer cope, optimize the DBMS. Hibernate cache is unlikely to give a tangible increase,(the amount of information in the question allows only the general case to be discussed).
Any software caches require actual programming. If you know exactly which entities need to be cached and in what mode, and there are few types, then perhaps the easiest way would be to simply create a Map right in your code and implement all the work with it yourself. It makes sense to connect third-party products if the logic of caching and clearing the cache is complex, and even, for example, a distributed cache is required. Then yes - see individual products.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question