Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hibernate 6 Second Level Cache

Did anyone try to get hibernate-ehcache to work with latest Spring Boot 3 and hibernate 6? Taken from the last updates to the library (6.0.0-alpha7 with last update in 2021) this seems not to be continued? Is there something new to replace it that I have missed so far?

like image 507
mbodev Avatar asked Jul 29 '26 09:07

mbodev


2 Answers

The recommended approach is to use the JCache API instead of plain EhCache to do the caching. EhCache supports the JCache API so you can still use EhCache as the cache implementation.

Use the hibernate-jcache dependency and configure it accordingly.

How to do the configuration is explained here in the Hibernate documentation.

like image 107
M. Deinum Avatar answered Jul 30 '26 23:07

M. Deinum


I wrote a post about how to use redisson as 2LC with spring boot and hibernate: https://blog.coffeebeans.at/archives/1919. I got rid of ehcache as redis was already in the project and redisson provides a compatible implementation that uses redis =)

If you have any questions, please let me know.

Thanks to M. Deinum for your hint to jcache to replace hibernate-ehcache.

like image 38
mbodev Avatar answered Jul 31 '26 00:07

mbodev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!