Skip to content
Advertisement

How to use Redis as L2 cache on Hibernate?

I have a spring boot application and need to setup Redis as l2 cache on hibernate.

My prop file looks like:

JavaScript

I created a custom region factory because I don’t want to use json or yaml files. (right now, the parameters are hardcoded). CustomRegionFactory class looks like:

JavaScript

Using redis-cli I found out that all my entities annotated with @Cacheable are listed when using the command keys *. Until here I thought everything worked fine, but using the postgres logging resources I found out that the queries are hitting the database.

Does somebody have any tips to make it works?

Advertisement

Answer

I found out that using @Cacheable from hibernate will solve everything.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement