Coverage for conf/settings/caches.py: 100%
7 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 06:14 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 06:14 +0000
1from decouple import config
4# Caches
6REDIS_HOST = config("REDIS_HOST", default="localhost")
7REDIS_PORT = config("REDIS_PORT", default=6379, cast=int)
8REDIS_PASSWORD = config("REDIS_PASSWORD", default="")
11def _make_cache_config(dbnum: int, **overrides) -> dict:
12 return {
13 "BACKEND": "django_redis.cache.RedisCache",
14 "LOCATION": f"redis://{REDIS_HOST}:{REDIS_PORT}/{dbnum}",
15 "OPTIONS": {
16 "CLIENT_CLASS": "django_redis.client.DefaultClient",
17 }
18 | overrides.pop("OPTIONS", {}),
19 } | overrides
22CACHES = {
23 # Site cache writes to 'default'
24 "default": _make_cache_config(0),
25 # Used for tracking tallied figures that shouldn't expire and are indexed
26 # with a timestamp range (for example, the key could a timestamp valid
27 # for a given week), allowing historical data analysis.
28 "tallies": _make_cache_config(3, TIMEOUT=None),
29}