0

I'm trying to integrate apache superset to my multi tenant application and I'm having the below issue regarding caching:

superset provide almost everything we need to be easily configured in superset_config.py, but in my case I'm trying to set the caching key to have the tenant ID so I can have data segregation between the tenants, so what I should do is to get the tenant ID from the session and append it to the key

Note that I'm running superset:2.0.0

Below are my caching configurations in superset_config.py:

FILTER_STATE_CACHE_CONFIG = {
    'CACHE_TYPE': 'RedisCache',
    'CACHE_DEFAULT_TIMEOUT': 86400,
    'CACHE_KEY_PREFIX': "FILTER_STATE_CACHE_CONFIG",
    'CACHE_REDIS_URL': 'redis://xxx.xxx.xxx.xxx:6379/0'
}

DATA_CACHE_CONFIG = {
    "CACHE_TYPE": "RedisCache",
    "CACHE_KEY_PREFIX": "DATA_CACHE_CONFIG_",  # make sure this string is unique to avoid collisions
    "CACHE_DEFAULT_TIMEOUT": 86400,  # 60 seconds * 60 minutes * 24 hours
    'CACHE_REDIS_URL': 'redis://xxx.xxx.xxx.xxx:6379/0'
}

EXPLORE_FORM_DATA_CACHE_CONFIG = {
    "CACHE_TYPE": "RedisCache",
    "CACHE_KEY_PREFIX": "EXPLORE_FORM_DATA_CACHE_CONFIG_",  # make sure this string is unique to avoid collisions
    "CACHE_DEFAULT_TIMEOUT": 86400,  # 60 seconds * 60 minutes * 24 hours
    'CACHE_REDIS_URL': 'redis://xxx.xxx.xxx.xxx:6379/0'
}

What I did is I update the cache.py file in superset/utils/ and I amend the set_and_log_cache function to read the tenant id from the session: cache_key = cache_key + "" + "Tenant:" + str(session["Tenant_Id"])

I can see the keys have their corresponding tenant ids in the redis CLI but the caching is not working in superset!

Is there any sort of configuration I should add or anything that I'm missing? I would really be thankful for any kind of help

Note that I'm using docker exec command to enter the container then I made my code changes and committed to a new image, then I use the new image in the docker-compose-non-dev.yml

Antu
  • 2,197
  • 3
  • 25
  • 40

0 Answers0