How to determine the numbers of cache entries from Hibernate 2nd level Ehcache?

35 views Asked by At

In a Spring Boot 3 application using Hibernate 6 I've set up Ehcache 3 for 2nd level caching.

Now I want to determine the number of entries per cache region.

All I've found regarding this task is a short outdated snippet on Baeldung:

int size = net.sf.ehcache.CacheManager.ALL_CACHE_MANAGERS.get(0)
  .getCache("com.baeldung.hibernate.cache.model.Foo").getSize();
assertThat(size, greaterThan(0));

Unfortunately, the CacheManager provided by Ehcache 3 no longer has an API to access as shown.

Is there any other way to retrieve the current size (number of entries stored) of a given cache region?

0

There are 0 answers