<p>I have superset installed via helmchart in my kubernetes environment, I took everything from official documentation and repository: <a href="https://github.com/apache/superset" rel="nofollow noreferrer">https://github.com/apache/superset</a></p>
<p>I'm trying to archive a data autorefresh of the dashboard every 12 hours via helmchart and not via the UI; I read that this can be done enabling superset cache so data will be cached for 12 hours and then dynamically refreshed and everyone that access superset UI can see the same values.</p>
<p>My problem now is one.... I can see the cache configuration on the superset/config.py file:</p>
<pre><code># Default cache for Superset objects
CACHE_CONFIG: CacheConfig = {&quot;CACHE_TYPE&quot;: &quot;NullCache&quot;}

# Cache for datasource metadata and query results
DATA_CACHE_CONFIG: CacheConfig = {&quot;CACHE_TYPE&quot;: &quot;NullCache&quot;}

# Cache for dashboard filter state (`CACHE_TYPE` defaults to `SimpleCache` when
#  running in debug mode unless overridden)
FILTER_STATE_CACHE_CONFIG: CacheConfig = {
    &quot;CACHE_DEFAULT_TIMEOUT&quot;: int(timedelta(days=90).total_seconds()),
    # should the timeout be reset when retrieving a cached value
    &quot;REFRESH_TIMEOUT_ON_RETRIEVAL&quot;: True,
}

# Cache for explore form data state (`CACHE_TYPE` defaults to `SimpleCache` when
#  running in debug mode unless overridden)
EXPLORE_FORM_DATA_CACHE_CONFIG: CacheConfig = {
    &quot;CACHE_DEFAULT_TIMEOUT&quot;: int(timedelta(days=7).total_seconds()),
    # should the timeout be reset when retrieving a cached value
    &quot;REFRESH_TIMEOUT_ON_RETRIEVAL&quot;: True,
}
</code></pre>
<p>As per documentation I'm using the <strong>configOverrides</strong> section of the helmchart to overwrite the default values and enable the cache of config, data, filter ad explore but I can't find any example of how to do it and everything I try always fail in helmrelease.</p>
<p>I try to read the helmchart but looks that it take all the <strong>configOverrides</strong> section and I was not able to find where it overwrite those specific values.</p>
<p>Some example of what I try to overwrite, for example enabling some flag works without problem:</p>
<pre><code>configOverrides:
  enable_flags: |
    FEATURE_FLAGS = {
        &quot;DASHBOARD_NATIVE_FILTERS&quot;: True,
        &quot;ENABLE_TEMPLATE_PROCESSING&quot;: True,
        &quot;DASHBOARD_CROSS_FILTERS&quot;: True,
        &quot;DYNAMIC_PLUGINS&quot;: True,
        &quot;VERSIONED_EXPORT&quot;: True,
        &quot;DASHBOARD_RBAC&quot;: True,
    }
</code></pre>
<p>But if I try to overwrite one or more cache value it fail (config.py <a href="https://github.com/apache/superset/blob/master/superset/config.py" rel="nofollow noreferrer">https://github.com/apache/superset/blob/master/superset/config.py</a>), this is one of the different way I try to overwrite checking the helm value file, the template and the superser config.py (and checkign other articles):</p>
<pre><code>configOverrides:
  cache_config: |
    CACHE_CONFIG: CacheConfig = {
        'CACHE_TYPE': 'RedisCache',
        'CACHE_DEFAULT_TIMEOUT': int(timedelta(hours=6).total_seconds()),
        'CACHE_KEY_PREFIX': 'superset_cache_'
      }
  data_cache_config: |
    DATA_CACHE_CONFIG: CacheConfig = {
        'CACHE_TYPE': 'RedisCache',
        'CACHE_DEFAULT_TIMEOUT': int(timedelta(hours=6).total_seconds()),
        'CACHE_KEY_PREFIX': 'superset_data_'
    }
  filter_cache_config: |
    FILTER_STATE_CACHE_CONFIG: CacheConfig = {
        'CACHE_TYPE': 'RedisCache',
        'CACHE_DEFAULT_TIMEOUT': int(timedelta(hours=6).total_seconds()),
        'CACHE_KEY_PREFIX': 'superset_filter_'
    }
  explore_cache_config: |
    EXPLORE_FORM_DATA_CACHE_CONFIG: CacheConfig = {
        'CACHE_TYPE': 'RedisCache',
        'CACHE_DEFAULT_TIMEOUT': int(timedelta(hours=6).total_seconds()),
        'CACHE_KEY_PREFIX': 'superset_explore_'
    }
</code></pre>
<p>Any help pls? Or redirect to some good documentation that has example! Ps the redis installation I have it's the default one created by the helmchart, I didn't change anything on it.</p>

Carlo 1585
<p><strong>TL;DR;</strong> your <code>configOverrides</code> should look like this:</p>
<pre><code>configOverrides:
  cache_config: |
    from datetime import timedelta
    from superset.superset_typing import CacheConfig

    CACHE_CONFIG: CacheConfig = {
        'CACHE_TYPE': 'RedisCache',
        'CACHE_DEFAULT_TIMEOUT': int(timedelta(hours=6).total_seconds()),
        'CACHE_KEY_PREFIX': 'superset_cache_'
      }
    
    DATA_CACHE_CONFIG: CacheConfig = {
        'CACHE_TYPE': 'RedisCache',
        'CACHE_DEFAULT_TIMEOUT': int(timedelta(hours=6).total_seconds()),
        'CACHE_KEY_PREFIX': 'superset_data_'
    }
    FILTER_STATE_CACHE_CONFIG: CacheConfig = {
        'CACHE_TYPE': 'RedisCache',
        'CACHE_DEFAULT_TIMEOUT': int(timedelta(hours=6).total_seconds()),
        'CACHE_KEY_PREFIX': 'superset_filter_'
    }

    EXPLORE_FORM_DATA_CACHE_CONFIG: CacheConfig = {
        'CACHE_TYPE': 'RedisCache',
        'CACHE_DEFAULT_TIMEOUT': int(timedelta(hours=6).total_seconds()),
        'CACHE_KEY_PREFIX': 'superset_explore_'
    }
</code></pre>
<h2>Details:</h2>
<p>After running a helm install with your settings, your config file will look a bit like this:</p>
<pre><code>import os
from cachelib.redis import RedisCache
...
CACHE_CONFIG = {
      'CACHE_TYPE': 'redis',
      'CACHE_DEFAULT_TIMEOUT': 300,
      'CACHE_KEY_PREFIX': 'superset_',
      'CACHE_REDIS_HOST': env('REDIS_HOST'),
      'CACHE_REDIS_PORT': env('REDIS_PORT'),
      'CACHE_REDIS_PASSWORD': env('REDIS_PASSWORD'),
      'CACHE_REDIS_DB': env('REDIS_DB', 1),
}
DATA_CACHE_CONFIG = CACHE_CONFIG
...
# Overrides
# cache_config
CACHE_CONFIG: CacheConfig = {
    'CACHE_TYPE': 'RedisCache',
    'CACHE_DEFAULT_TIMEOUT': int(timedelta(hours=6).total_seconds()),
    'CACHE_KEY_PREFIX': 'superset_cache_'
  }

# data_cache_config
DATA_CACHE_CONFIG: CacheConfig = {
    'CACHE_TYPE': 'RedisCache',
    'CACHE_DEFAULT_TIMEOUT': int(timedelta(hours=6).total_seconds()),
    'CACHE_KEY_PREFIX': 'superset_data_'
}

# enable_flags
FEATURE_FLAGS = {
    &quot;DASHBOARD_NATIVE_FILTERS&quot;: True,
    &quot;ENABLE_TEMPLATE_PROCESSING&quot;: True,
    &quot;DASHBOARD_CROSS_FILTERS&quot;: True,
    &quot;DYNAMIC_PLUGINS&quot;: True,
    &quot;VERSIONED_EXPORT&quot;: True,
    &quot;DASHBOARD_RBAC&quot;: True,
}

# explore_cache_config
EXPLORE_FORM_DATA_CACHE_CONFIG: CacheConfig = {
    'CACHE_TYPE': 'RedisCache',
    'CACHE_DEFAULT_TIMEOUT': int(timedelta(hours=6).total_seconds()),
    'CACHE_KEY_PREFIX': 'superset_explore_'
}
# filter_cache_config
FILTER_STATE_CACHE_CONFIG: CacheConfig = {
    'CACHE_TYPE': 'RedisCache',
    'CACHE_DEFAULT_TIMEOUT': int(timedelta(hours=6).total_seconds()),
    'CACHE_KEY_PREFIX': 'superset_filter_'
}
</code></pre>
<p>When I looked at the pod logs, there were a lot of errors due to the function <code>timedelta</code> not being defined, here is a sample of the logs I can see:</p>
<pre><code>File &quot;/app/pythonpath/superset_config.py&quot;, line 42, in &lt;module&gt;
    'CACHE_DEFAULT_TIMEOUT': int(timedelta(hours=6).total_seconds()),
    NameError: name 'timedelta' is not defined
</code></pre>
<p>The file in question, <code>/app/pythonpath/superset_config.py</code> , is loaded via an import <a href="https://github.com/apache/superset/blob/master/superset/config.py#L1587" rel="nofollow noreferrer">here</a> as mentioned in <a href="https://github.com/apache/superset/blob/master/superset/config.py#L19" rel="nofollow noreferrer">the comment at the top of the file</a>.</p>
<p>Notice that you're writing a fresh new <code>.py</code> file; which means that you need to add <code>from datetime import timedelta</code> at the top in the configOverrides section.</p>
<p>However, since the doc in the helm chart states the following warning <code>WARNING: the order is not guaranteed Files can be passed as helm --set-file configOverrides.my-override=my-file.py</code>, and you clearly want to use the function <code>timedelta</code>, we must combine all three blocks under the same section like this:</p>
<pre><code>configOverrides:
  cache_config: |
    from datetime import timedelta

    CACHE_CONFIG: CacheConfig = {
        'CACHE_TYPE': 'RedisCache',
        'CACHE_DEFAULT_TIMEOUT': int(timedelta(hours=6).total_seconds()),
        'CACHE_KEY_PREFIX': 'superset_cache_'
      }
    
    DATA_CACHE_CONFIG: CacheConfig = {
        'CACHE_TYPE': 'RedisCache',
        'CACHE_DEFAULT_TIMEOUT': int(timedelta(hours=6).total_seconds()),
        'CACHE_KEY_PREFIX': 'superset_data_'
    }
    FILTER_STATE_CACHE_CONFIG: CacheConfig = {
        'CACHE_TYPE': 'RedisCache',
        'CACHE_DEFAULT_TIMEOUT': int(timedelta(hours=6).total_seconds()),
        'CACHE_KEY_PREFIX': 'superset_filter_'
    }

    EXPLORE_FORM_DATA_CACHE_CONFIG: CacheConfig = {
        'CACHE_TYPE': 'RedisCache',
        'CACHE_DEFAULT_TIMEOUT': int(timedelta(hours=6).total_seconds()),
        'CACHE_KEY_PREFIX': 'superset_explore_'
    }
</code></pre>
<p>Furthermore, you wanted to use the type <code>CacheConfig</code>, so we should also include an import for it at the top.</p>
