Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Commit 6f1d6b5

Browse files
authored
Add configuration to use cached sessions (#1293)
1 parent 7090578 commit 6f1d6b5

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

codecov/settings_base.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from sentry_sdk.integrations.redis import RedisIntegration
99
from sentry_sdk.scrubber import DEFAULT_DENYLIST, EventScrubber
1010
from shared.django_apps.db_settings import *
11+
from shared.helpers.redis import get_redis_url
1112
from shared.license import startup_license_logging
1213

1314
from utils.config import SettingsModule, get_config, get_settings_module
@@ -265,10 +266,26 @@
265266
COOKIE_SAME_SITE = "Lax"
266267
COOKIE_SECRET = get_config("setup", "http", "cookie_secret")
267268
COOKIES_DOMAIN = get_config("setup", "http", "cookies_domain", default=".codecov.io")
269+
270+
271+
# Cache configuration
272+
CACHES = {
273+
"default": {
274+
"BACKEND": "django.core.cache.backends.redis.RedisCache",
275+
"LOCATION": get_redis_url(),
276+
}
277+
}
278+
279+
280+
# Session configuration
268281
SESSION_COOKIE_DOMAIN = get_config(
269282
"setup", "http", "cookies_domain", default=".codecov.io"
270283
)
271284
SESSION_COOKIE_SECURE = get_config("setup", "secure_cookie", default=True)
285+
286+
SESSION_ENGINE = "django.contrib.sessions.backends.cached_db"
287+
288+
272289
# Defaulting to 'not found' as opposed to 'None' to avoid None somehow getting through as a bearer token. Token strings can't have spaces, hence 'not found' can never be forced as a header input value
273290
SUPER_API_TOKEN = os.getenv("SUPER_API_TOKEN", "not found")
274291
CODECOV_INTERNAL_TOKEN = os.getenv("CODECOV_INTERNAL_TOKEN", "not found")

0 commit comments

Comments
 (0)