django-cache-url
django-cache-url copied to clipboard
Multiple redis hosts throws error
Passing multiple redis hosts throws an error:
>>> import django_cache_url
>>> django_cache_url.parse("redis://my-redis.nydu4q.ng.0001.use1.cache.amazonaws.com:6379,my-redis-ro.nydu4q.ng.0001.use1.cache.amazonaws.com:6379")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.10/site-packages/django_cache_url/__init__.py", line 115, in parse
port = url.port if url.port else 6379
File "/usr/local/lib/python3.10/urllib/parse.py", line 178, in port
raise ValueError(message) from None
ValueError: Port could not be cast to integer value as '6379,my-redis-ro.nydu4q.ng.0001.use1.cache.amazonaws.com:6379'
If port is removed, there is no traceback, but produces incorrect configuration:
>>> django_cache_url.parse("redis://my-redis.nydu4q.ng.0001.use1.cache.amazonaws.com,my-redis-ro.nydu4q.ng.0001.use1.cache.amazonaws.com")
{'BACKEND': 'django.core.cache.backends.redis.RedisCache', 'LOCATION': 'redis://my-redis.nydu4q.ng.0001.use1.cache.amazonaws.com,my-redis-ro.nydu4q.ng.0001.use1.cache.amazonaws.com:6379/0'}
Contributions welcome. 🙂