0

Currently I am using Redis for my Flask app and having the configuration as below.

redis_config = redis.StrictRedis(
host='myhost',
port=myport,
db=0,
username='',
password='mypass',
ssl=True,
ssl_cert_reqs='required',
ssl_ca_certs='redis_certs/ca.crt',
ssl_certfile='redis_certs/client.crt',
ssl_keyfile='/redis_certs/client.key',

) and then passing the same to cache config.

CACHE_CONFIG = {
'CACHE_TYPE': 'redis',
'CACHE_DEFAULT_TIMEOUT': 60 * 60 * 24, # 1 day default (in secs)
'CACHE_KEY_PREFIX': 'someprefix',
#'CACHE_REDIS_URL': 'redis://xyz:1234/1',
'CACHE_REDIS_HOST': redis_config,

}

If I want to change the config to redis_sentinel instead of Redis for better availibality. I am not able to understand the configuration mentioned in Flask-cachig doc.

CACHE_KEY_PREFIX
CACHE_REDIS_SENTINELS
CACHE_REDIS_SENTINEL_MASTER
CACHE_REDIS_PASSWORD
CACHE_REDIS_DB

and how to configure along with SSl? I am new to redis and did not find anything helpful resource online.

1 Answers1

0

I'm new with Redis too, and now I'm still checking on this. I never try with SSL yet, so this will only connect to redis sentinel only. What I was do is this config.

CACHE_CONFIG = {
  'CACHE_TYPE': 'redissentinel',
  'CACHE_KEY_PREFIX': 'someprefix',
  'CACHE_REDIS_SENTINELS': [('your_sentinel_host1', 26379), ('your_sentinel_host2', 26379), ('your_sentinel_host3', 26379)],
  'CACHE_REDIS_SENTINEL_MASTER': 'your_master_name_from_sentinel'
}

I'm testing with this docker and it's work.

chaiyut
  • 36
  • 1
  • 5