dev: redis instance rewrite for ssl settings and remove REDIS_TLS env variable

This commit is contained in:
vamsi 2023-01-02 19:41:47 +05:30
parent 70e96be8fa
commit a960ddedf7
3 changed files with 12 additions and 15 deletions

View File

@ -163,11 +163,6 @@ CSRF_COOKIE_SECURE = True
REDIS_URL = os.environ.get("REDIS_URL") REDIS_URL = os.environ.get("REDIS_URL")
REDIS_TLS_URL = os.environ.get("REDIS_TLS_URL")
if REDIS_TLS_URL:
REDIS_URL = REDIS_TLS_URL
CACHES = { CACHES = {
"default": { "default": {
"BACKEND": "django_redis.cache.RedisCache", "BACKEND": "django_redis.cache.RedisCache",

View File

@ -1,13 +1,20 @@
import redis import redis
import os
from django.conf import settings from django.conf import settings
from urllib.parse import urlparse from urllib.parse import urlparse
def redis_instance(): def redis_instance():
if settings.REDIS_URL: if settings.REDIS_URL:
ri = redis.from_url(settings.REDIS_URL, db=0) url = urlparse(settings.REDIS_URL)
ri = redis.Redis(
host=url.hostname,
port=url.port,
password=url.password,
ssl=True,
ssl_cert_reqs=None,
)
else: else:
ri = redis.StrictRedis(host=settings.REDIS_HOST, port=settings.REDIS_PORT, db=0) ri = redis.StrictRedis(
host=settings.REDIS_HOST, port=settings.REDIS_PORT, db=0
)
return ri return ri

View File

@ -163,11 +163,6 @@ CSRF_COOKIE_SECURE = True
REDIS_URL = os.environ.get("REDIS_URL") REDIS_URL = os.environ.get("REDIS_URL")
REDIS_TLS_URL = os.environ.get("REDIS_TLS_URL")
if REDIS_TLS_URL:
REDIS_URL = REDIS_TLS_URL
CACHES = { CACHES = {
"default": { "default": {
"BACKEND": "django_redis.cache.RedisCache", "BACKEND": "django_redis.cache.RedisCache",