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

Support/redis config update #1056

Merged
merged 2 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ services:
- ./database_dumps:/database_dumps

redis:
image: redis:6
image: redis:7.2
expose:
- 6379
logging:
Expand Down
33 changes: 29 additions & 4 deletions rca/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,40 @@
# usually use Redis in production and database backend on staging and dev. In
# order to use database cache backend you need to run
# "django-admin createcachetable" to create a table for the cache.

#
# Do not use the same Redis instance for other things like Celery!
if "REDIS_URL" in env:

# Prefer the TLS connection URL over non
REDIS_URL = env.get("REDIS_TLS_URL", env.get("REDIS_URL"))

if REDIS_URL:
connection_pool_kwargs = {}

if REDIS_URL.startswith("rediss"):
# Heroku Redis uses self-signed certificates for secure redis conections. https://stackoverflow.com/a/66286068
# When using TLS, we need to disable certificate validation checks.
connection_pool_kwargs["ssl_cert_reqs"] = None

redis_options = {
"IGNORE_EXCEPTIONS": True,
"SOCKET_CONNECT_TIMEOUT": 2, # seconds
"SOCKET_TIMEOUT": 2, # seconds
"CONNECTION_POOL_KWARGS": connection_pool_kwargs,
}

CACHES = {
"default": {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": env["REDIS_URL"],
}
"LOCATION": REDIS_URL + "/0",
"OPTIONS": redis_options,
},
"renditions": {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": REDIS_URL + "/1",
"OPTIONS": redis_options,
},
}
DJANGO_REDIS_LOG_IGNORED_EXCEPTIONS = True
else:
CACHES = {
"default": {
Expand Down
Loading