# JCache does not have support for extended statistics?

**URL:** <https://discourse.hibernate.org/t/jcache-does-not-have-support-for-extended-statistics/1951>\
**Category:** Hibernate ORM\
**Created:** [December 31, 2018, 4:51pm UTC](https://discourse.hibernate.org/t/jcache-does-not-have-support-for-extended-statistics/1951 "2018-12-31T16:51:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mekane](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/mekane/32/679_2.png) [@mekane](https://discourse.hibernate.org/u/mekane)\
**Post date:** [December 31, 2018, 4:51pm UTC](https://discourse.hibernate.org/t/jcache-does-not-have-support-for-extended-statistics/1951/1 "2018-12-31T16:51:57Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![vlad](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/vlad/32/658_2.png) [@vlad](https://discourse.hibernate.org/u/vlad)\
**Post date:** [December 31, 2018, 5:13pm UTC](https://discourse.hibernate.org/t/jcache-does-not-have-support-for-extended-statistics/1951/2 "2018-12-31T17:13:23Z")

</div>

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:

> <https://stackoverflow.com/questions/40453859/how-to-get-ehcache-3-1-statistics>

---

<div class="post-metadata">

**Author:** ![mekane](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/mekane/32/679_2.png) [@mekane](https://discourse.hibernate.org/u/mekane)\
**Post date:** [January 2, 2019, 3:24pm UTC](https://discourse.hibernate.org/t/jcache-does-not-have-support-for-extended-statistics/1951/3 "2019-01-02T15:24:19Z")

</div>

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:

```auto
<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>

```
