Skip to content

Commit

Permalink
settings: add cache configuration (bug 1870285)
Browse files Browse the repository at this point in the history
- add fallback DB backend
- add environment based redis configuration
  • Loading branch information
zzzeid committed Dec 15, 2023
1 parent 5b3c710 commit 5ea6514
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/lando/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,27 @@
}
}

REDIS_CONFIG = {
"HOST": os.getenv("REDIS_HOST"),
"PORT": os.getenv("REDIS_PORT"),
"USERNAME": os.getenv("REDIS_USERNAME"),
"PASSWORD": os.getenv("REDIS_PASSWORD"),
}

CACHES = {}

if all(REDIS_CONFIG.values()):
CACHES["default"] = {
"BACKEND": "django.core.cache.backends.redis.RedisCache",
"LOCATION": [
"redis://{USER}:{PASSWORD}@{HOST}:{PORT}".format(**REDIS_CONFIG),
],
}
else:
CACHES["default"] = {
"BACKEND": "django.core.cache.backends.db.DatabaseCache",
"LOCATION": "lando_cache",
}

# Password validation
# https://docs.djangoproject.com/en/dev/ref/settings/#auth-password-validators
Expand Down

0 comments on commit 5ea6514

Please sign in to comment.