Skip to content

Django's RedisCache OPTIONS needs to be lowercase #517

Open
@jgoret

Description

@jgoret

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions