Current cache increases with each unique sample combination
Mybatis only allows to set number of object not size
The internal portals are still going down from time to time. We turned off mybatis caching completely in the public portal, but couldn't do that for the private portal since it would significantly impact the performance.
I remember @n1zea144 or @ersinciftci mentioned there was some way to cache per sample / gene, instead of per query (set of sampels, set of genes).
@jjgao Timely message. I understand from @zhx828 that the built-in Mybatis cache is not working as expected. I thought I would look into using Ehcache (hibernate cache system) with MyBatis. For one, its widely used and we've used it in other projects. Also, there are tools available to monitor the cache. This will allow us to confirm the expected behavior based on our settings.
@jjgao Actually, I'm not set on using Ehcache yet. After some further investigation, it looks like we can implement our own custom cache. I think its more important to pursue this route as the structure of keys/values in the cache created by the MyBatis cache implementation is not ideal for our use-cases. As a start I'm going to implement a custom cache which simply proxies the MyBatis cache implementation but also logs the key/values just to confirm our suspicions (I'll make this available on a dev server).
If this confirms our suspicions, we will then have the flexibility to implement our custom cache from scratch or utilizing Ehcache or even REDIS. Regardless of the path we chose, I think we should have a discussion about how we should structure our cache.
@jjgao @ersinciftci @inodb @zhx828 @sheridancbio I now have a custom cache implementation in place. It does confirm that keys are generated for each namespace/query/parameter list (see attached). In fact, MyBatis has defined a CacheKey type and a reference to an instance of this is stored in the cache, which ultimately in the MyBatis library is just a HashMap (depending on eviction method, there is a different decorator class). Based on my observation, the slightest change in the query does result in a different cache key.
I see a few options going forward:
In either scenario, we have to figure out what the cache organization should be - i.e., study-sample, study-patient, study-patient-sample.
I think this is worthy of a discussion to figure out next steps.
Debugger screen capture of a MyBatis cache key during a cache.put operation.

@jjgao We will take this task on in the pipeline scrum The week of July 30 (many of us our out of the lab next week). It would be helpful if you can prioritize the endpoints that require addressing. Happy to discuss further in the lab.
@n1zea144 thanks for the analysis! Happy to discuss further.
I am looking into this and see if we can turn off caching for private portals.
We have turned it off for public portal, but when turning it off for private portals, they become very slow.
@n1zea144 I am closing this one. Please create separate issues for caching improvement you are working on.