question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to set cache properties for Hibernate scond level cache?

See original GitHub issue

I’m working on a Java spring project where I have multiple entities to be cached using @Cache annotation, ex: @Cache(usage = CacheConcurrencyStrategy.READ_WRITE ,region = "cache1")

I have set spring.jpa.properties.hibernate.cache.region.factory_class to be RedissonRegionFactory

As I’m using Redis cache as Hibernate second Level cache, I want a way to customize the properties of each cache region in a Java class, by properties I mean the TTL and maxEntriesLocalHeap.

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
mrnikocommented, Nov 17, 2022

You can specify region name as well.

spring.jpa.properties.hibernate.cache.redisson.my_object.eviction.max_entries=
spring.jpa.properties.hibernate.cache.redisson.my_object.expiration.time_to_live=
spring.jpa.properties.hibernate.cache.redisson.my_object.expiration.max_idle_time=

spring.jpa.properties.hibernate.cache.redisson.my_collection.expiration.time_to_live=
spring.jpa.properties.hibernate.cache.redisson.my_collection.expiration.max_idle_time=
0reactions
AseelAbushhadehcommented, Nov 17, 2022

You can specify region name as well.

spring.jpa.properties.hibernate.cache.redisson.my_object.eviction.max_entries=
spring.jpa.properties.hibernate.cache.redisson.my_object.expiration.time_to_live=
spring.jpa.properties.hibernate.cache.redisson.my_object.expiration.max_idle_time=

spring.jpa.properties.hibernate.cache.redisson.my_collection.expiration.time_to_live=
spring.jpa.properties.hibernate.cache.redisson.my_collection.expiration.max_idle_time=

Thanks it works!! Hoping I can find a way to do that in a java class.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Hibernate Second-Level Cache - Baeldung
In order to make an entity eligible for second-level caching, we'll annotate it with the Hibernate specific @org.hibernate.annotations.Cache ...
Read more >
Hibernate EHCache - Hibernate Second Level Cache
We use org.hibernate.annotations.Cache annotation to provide the caching configuration. org.hibernate.annotations.CacheConcurrencyStrategy is ...
Read more >
Hibernate Second Level Cache - Javatpoint
Hibernate Second Level Cache Example · 1) Create the persistent class using Maven. · 2) Add project information and configuration in pom.xml file....
Read more >
How to enable second level cache in Hibernate - Stack Overflow
Set the following Hibernate properties: <property name="hibernate.cache. · Add an ehcache.xml file in your classpath, containing the cache ...
Read more >
Hibernate Second-Level Cache Explained - Hazelcast
A Hibernate second-level cache is one of the data caching components available in the Hibernate object-relational mapping (ORM) library.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found