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

temp fix to disable redis #841

Merged
merged 2 commits into from
Jun 24, 2024
Merged
Changes from 1 commit
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
32 changes: 20 additions & 12 deletions src/dso_api/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
DSO_API_LOG_LEVEL = env.str("DSO_API_LOG_LEVEL", "INFO")
DSO_API_AUDIT_LOG_LEVEL = env.str("DSO_API_AUDIT_LOG_LEVEL", "INFO")
SENTRY_BLOCKED_PATHS: Final[list[str]] = env.list("SENTRY_BLOCKED_PATHS", default=[])
ENABLE_REDIS = env.bool("DISABLE_REDIS", False)

STATIC_HOST = env.str("STATIC_HOST", "")
STATIC_URL = f"{STATIC_HOST}/v1/static/"
Expand Down Expand Up @@ -199,19 +200,26 @@
if len(DATABASES) > 1:
DATABASE_ROUTERS = ["dso_api.router.DatabaseRouter"]

# Configure cache from a secret, so we cannot use CACHE_URL
# because that would expose redis passwd in an env var.
redis_password = Path(env.str("REDIS_PASSWD_PATH")).read_text()
redis_host = env.str("REDIS_HOSTNAME")
redis_port = env.int("REDIS_PORT", 6379)
CACHES = {
"default": {
"BACKEND": "django_redis.cache.RedisCache",
# "LOCATION": "redis://username:[email protected]:6379",
# We leave out the username, defaults to `default` for redis
"LOCATION": f"redis://:{redis_password}@{redis_host}:{redis_port}",
if ENABLE_REDIS:
# Configure cache from a secret, so we cannot use CACHE_URL
# because that would expose redis passwd in an env var.
redis_password = Path(env.str("REDIS_PASSWD_PATH")).read_text()
redis_host = env.str("REDIS_HOSTNAME")
redis_port = env.int("REDIS_PORT", 6379)
CACHES = {
"default": {
"BACKEND": "django_redis.cache.RedisCache",
# "LOCATION": "redis://username:[email protected]:6379",
# We leave out the username, defaults to `default` for redis
"LOCATION": f"redis://:{redis_password}@{redis_host}:{redis_port}",
}
}
else:
CACHES = {
"default": {
"BACKEND": "django.core.cache.backends.dummy.DummyCache",
}
}
}

else:
# Regular development
Expand Down
Loading