Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Django's RedisCache OPTIONS needs to be lowercase #517

Open
jgoret opened this issue Jan 18, 2024 · 0 comments
Open

Django's RedisCache OPTIONS needs to be lowercase #517

jgoret opened this issue Jan 18, 2024 · 0 comments

Comments

@jgoret
Copy link

jgoret commented Jan 18, 2024

We're currently moving our django cache and Celery broker to redis with TLS enabled and need to pass the ssl_cert_reqs parameter to the underlying redis connection.

We're using django-environ to get both settings with a code similar to this :

CACHES = {
    "default": environ.cache(var="CACHE_URL", default="locmemcache://unique-snowflake"),
}

CELERY_BROKER_URL = environ.str(
    "CELERY_BROKER_URL",
    default="amqp://rabbit:rabbit@localhost:5672/",
)

And both environments variables are set like this : rediss://<user>:<password>@<hostname>:<port>/<database_number>?ssl_cert_reqs=none

Everything works fine for Celery but for the cache we're getting an exception because all query parameters are forced to uppercase and the standard Django redis cache (and the underlying redis-py lib) await them in lowercase :

TypeError: __init__() got an unexpected keyword argument 'SSL_CERT_REQS'
[...]
  File "redis/client.py", line 1266, in execute_command
    conn = self.connection or pool.get_connection(command_name, **options)
  File "redis/connection.py", line 1456, in get_connection
    connection = self.make_connection()
  File "redis/connection.py", line 1496, in make_connection
    return self.connection_class(**self.connection_kwargs)
  File "redis/connection.py", line 1104, in __init__
    super().__init__(**kwargs)
  File "redis/connection.py", line 960, in __init__
    super().__init__(**kwargs)

I know that the global lowercase options question was discussed in #87 but as django.core.cache.backends.redis.RedisCache is a natively supported cache scheme I think this should correctly handled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant