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:


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:

    <jcache:defaults default-template="myDefaults"/>

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

  <cache-template name="myDefaults">

  <cache-template name="tinyTemplate">

  <cache-template name="largeObjectDiskBackup">
      <disk unit="MB">100</disk>

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