[IMP] session_redis: allow configuring Redis URL instead of host & port.

Back-porting from [13] branch
This commit is contained in:
Miku Laitinen
2021-11-11 19:54:22 +01:00
committed by Yannick Vaucher
co-authored by Yannick Vaucher
parent 52570f9cb4
commit c2d40b84e1
2 changed files with 5 additions and 0 deletions
+3
View File
@@ -39,6 +39,7 @@ sentinel_port = int(os.environ.get('ODOO_SESSION_REDIS_SENTINEL_PORT', 26379))
host = os.environ.get('ODOO_SESSION_REDIS_HOST', 'localhost')
port = int(os.environ.get('ODOO_SESSION_REDIS_PORT', 6379))
prefix = os.environ.get('ODOO_SESSION_REDIS_PREFIX')
url = os.environ.get('ODOO_SESSION_REDIS_URL')
password = os.environ.get('ODOO_SESSION_REDIS_PASSWORD')
expiration = os.environ.get('ODOO_SESSION_REDIS_EXPIRATION')
anon_expiration = os.environ.get('ODOO_SESSION_REDIS_EXPIRATION_ANONYMOUS')
@@ -50,6 +51,8 @@ def session_store(self):
sentinel = Sentinel([(sentinel_host, sentinel_port)],
password=password)
redis_client = sentinel.master_for(sentinel_master_name)
elif url:
redis_client = redis.from_url(url)
else:
redis_client = redis.Redis(host=host, port=port, password=password)
return RedisSessionStore(redis=redis_client, prefix=prefix,