Skip to content

VAHub Back End Caching

Kantemir Tvorogov edited this page Aug 9, 2023 · 1 revision

Overview

VAHub widely uses caching to avoid data re-querying, re-calculation and re-composition for identical requests. Most part of data is read-only for VAHub and common for all users, so identical requests is a normal thing in ACUITY.

VAHub uses different caching solutions:

Both store cached values in file form.

Kryo cache

Location of file storage for Kryo cache is defined by property kryo.storage.location in main properties file of vahub-model module of VAHub project (currently named inmemory.properties due to history reasons). This file properties are loaded with com.acuity.visualisations.rawdatamodel.config.InmemoryConfig Spring configuration class. The discussed property value is injected into com.acuity.visualisations.rawdatamodel.dataproviders.common.DataProvider bean.

Typically, Kryo cache is used in ACUITY to create separate file cache for each dataset that contains all raw data of the requested type belonging to the given dataset. Data providers use this functionality to cache raw data before enrichment.

Ehcache cache

To define Ehcache file storage location, we have ehcache.xml configuration file in vahub-config module of VAHub project. The com.acuity.visualisations.config.ApplicationEhCacheConfig configuration file loads this file and uses it to provide a org.springframework.cache.ehcache.EhCacheManagerFactoryBean bean.

Ehcache caching is mostly used to cache results of frontend requests. To use this feature, one have to mark corresponding REST resource method with @Cacheable annotation, and the whole resource class — with @CacheConfig annotation, specifying keyGenerator = "datasetsKeyGenerator" and cacheResolver = "refreshableCacheResolver" (see com.acuity.visualisations.rest.resources.cardiac.CardiacResource as an example). These are custom ACUITY key generator and cache resolver implemented correspondingly in classes com.acuity.visualisations.common.cache.DatasetsKeyGenerator and com.acuity.visualisations.common.cache.RefreshableCacheResolver.

Clone this wiki locally