Pass Redis password to Redlock
import redlock
+import os
from rest_framework.serializers import ModelSerializer, Serializer, URLField,\
ValidationError
from cccatalog.api.controllers.link_controller import get_next_shortened_path
@@ -12,8 +13,9 @@ from rest_framework import serializers
__parsed_redis_url = urlparse(settings.CACHES['locks']['LOCATION'])
__host, __port = __parsed_redis_url.netloc.split(':')
__db_num = __parsed_redis_url.path[1] if __parsed_redis_url.path else 2
+__password = os.environ.get("REDIS_PASSWORD")
url_lock = redlock.Redlock(
- [{"host": __host, "port": __port, "db": __db_num}, ],
+ [{"host": __host, "port": __port, "db": __db_num, "password": __password}, ],
retry_count=0
)
