Configure Redis for Caching

Beginning v6.4.3 Redis is used as a default storage for user session information and has its own container as a part of MI Installation. Optionally, Redis can also be utilized to store cache. This article describes how to set up Redis as a storage for cache.

There are 2 layers of caching in Metric Insights application:

  1. Layer 1 caches user-related data: privileges, branding information, specific permissions, user sessions.
  2. Layer 2 caches Dataset queries' responses and queries to API endpoints.

By default, cache is stored locally in files, but this behavior can be overwritten. To improve performance Redis can be used as a cache storage by configuring the corresponding System Variables.

Table of contents:

Recommended Configuration of System Variables

  1. Access Admin > System > System Variables
  2. Configure Cache Layer Save Handler
  3. Configure Cache Layer Save Path
  4. Save Changes

System Variable API_QUERY_CACHE_LIFETIME is responsible for cache lifetime. If a Portal Page or an Element is changed via the UI, the changes will be visible in the Portal Page Viewer or via API only after API_QUERY_CACHE_LIFETIME seconds. If changes are made via API, they should be accessible immediately.

API_QUERY_CACHE_LIFETIME: 30

CACHE_LAYER_1_SAVE_PATH, CACHE_LAYER_2_SAVE_PATH:  <Redis path same as for session storage>, see Configure Cache Layer Save Path for details

CACHE_LAYER_1_SAVE_HANDLER, CACHE_LAYER_2_SAVE_PATH: redis

REDUCE_CACHE_USAGE: N

DEFAULT_DATASET_STORAGE_USE_CONFIG: Y

DA_ENABLE_OPENSEARCH: Y

1. Access Admin > System > System Variables

2. Configure Cache Layer Save Handler

  1. Search for CACHE_LAYER_1_SAVE_HADNLER and/or CACHE_LAYER_2_SAVE_HADNLER for Layers 1 and/or 2 correspondingly
  2. Click the gear icon
  3. Define where cache data is stored by selecting one of the following values:
    • files: Locally, the default value.
    • redis: In Redis container.
    • memcached: On Memcached server. This service needs to be configured separately, it is not a part of MI Installation.
      • Note: If memcached is selected, the value of CACHE_LAYER_1_SAVE_PATH and/or CACHE_LAYER_2_SAVE_PATH is <Custom Memcached server address>:11211
  4. [Save]

3. Configure Cache Layer Save Path

Note: The value(s) of  CACHE_LAYER_1_SAVE_PATH and/or CACHE_LAYER_2_SAVE_PATH will be ignored if the value(s) of CACHE_LAYER_1_SAVE_HADNLER and/or CACHE_LAYER_2_SAVE_HADNLER is set to default value files.

  1. Search for CACHE_LAYER_1_SAVE_PATH and/or CACHE_LAYER_2_SAVE_PATH for Layers 1 and/or 2 correspondingly
  2. Click the gear icon
  3. Define the specific path under which the cache data is stored. To get the needed path:
    1. Access the web container
    2. Execute env | grep PHP_SESSIONS_PATH
    3. Copy the value of PHP_SESSION_PATH and use it as the value of CACHE_LAYER_1_SAVE_PATH and/or CACHE_LAYER_2_SAVE_PATH
  4. [Save]

4. Save Changes

  1. [Commit Changes]
  2. [Proceed]