JCache does not have support for extended statistics?

I am trying to get statistics like size in memory and element count on disk for ehcache 3 implementation of jcache framework. why does this not support these extended statistics? i need stats on how much heap memory the cache is taking up, is there any other way to do this?

Most likely this has to be integrated into hibernate-jcache module. You need to create a Jira issue and add a reference to this StackOverflow answer:

1 Like

As a followup… to determine how much size the cache is on memory while testing, what i did was to convert the cache storage to disk only, then I navigated to the directory storing the cache and could see the size of the folder on hard drive, so I assume this is the same size that would have been taken up if the cache was stored in memory. Make sure to use setting hibernate.cache.use_structured_entries so you can see breakdown of different cached objects.

since I couldn’t find many examples of how to use disk storage for jcache/ehcache 3 xml file, which I believe is required for use with hibernate, here is an example for others below. The “largeObjectDiskBackup” cache uses a mixed tiering approach, you can remove the heap setting to store on disk only for the testing I described in first paragraph:

<config
  xmlns="http://www.ehcache.org/v3"
  xmlns:jcache="http://www.ehcache.org/v3/jsr107">
    
  <service>
    <jcache:defaults default-template="myDefaults"/>
  </service>

  <!-- Sets the path to the directory where cache files are created. -->
  <persistence directory="java.io.tmpdir"/>

  <cache-template name="myDefaults">
    <expiry>
      <tti>3600</tti>
    </expiry>
    <heap>10000</heap>
  </cache-template>

  <cache-template name="tinyTemplate">
    <expiry>
      <tti>600</tti>
    </expiry>
    <heap>100</heap>
  </cache-template>

  <cache-template name="largeObjectDiskBackup">
    <expiry>
      <tti>600</tti>
    </expiry>
    <resources>
      <disk unit="MB">100</disk>
      <heap>40</heap>
    </resources>
  </cache-template>

  <cache alias="uiowa.hawkirb.biz.projects.ProjectStatus" uses-template="tinyTemplate"/>
  <cache alias="uiowa.hawkirb.biz.forms.proj.ProjectForm" uses-template="largeObjectDiskBackup"/>

</config>