Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Remove django cache

IKarbowiakcbfa1529a2a8
diff --git a/.isort.cfg b/.isort.cfg
index 3c89d61a48..9b37a55b1d 100644
--- a/.isort.cfg
+++ b/.isort.cfg
@@ -1,2 +1,2 @@
[settings]
-known_third_party = PIL,babel,bleach,bootstrap4,braintree,celery,dj_database_url,dj_email_url,django,django_cache_url,django_countries,django_filters,django_measurement,django_prices,django_prices_openexchangerates,django_prices_vatlayer,draftjs_sanitizer,faker,freezegun,geolite2,google_measurement_protocol,graphene,graphene_django,graphene_django_optimizer,graphene_federation,graphql,graphql_jwt,graphql_relay,html5lib,html_to_draftjs,i18naddress,jwt,markdown,measurement,mptt,oauthlib,phonenumber_field,phonenumbers,prices,promise,pytest,razorpay,requests,sentry_sdk,six,social_core,storages,stripe,templated_email,text_unidecode,tqdm,versatileimagefield
+known_third_party = PIL,babel,bleach,bootstrap4,braintree,celery,dj_database_url,dj_email_url,django,django_countries,django_filters,django_measurement,django_prices,django_prices_openexchangerates,django_prices_vatlayer,draftjs_sanitizer,faker,freezegun,geolite2,google_measurement_protocol,graphene,graphene_django,graphene_django_optimizer,graphene_federation,graphql,graphql_jwt,graphql_relay,html5lib,html_to_draftjs,i18naddress,jwt,markdown,measurement,mptt,oauthlib,phonenumber_field,phonenumbers,prices,promise,pytest,razorpay,requests,sentry_sdk,six,social_core,storages,stripe,templated_email,text_unidecode,tqdm,versatileimagefield
diff --git a/common.env b/common.env
index cdad043323..c6172fe307 100644
--- a/common.env
+++ b/common.env
@@ -1,7 +1,6 @@
DATABASE_URL=postgres://saleor:saleor@db/saleor
OPENEXCHANGERATES_API_KEY
-CACHE_URL=redis://redis:6379/0
CELERY_BROKER_URL=redis://redis:6379/1
SECRET_KEY=changeme
JWT_VERIFY_EXPIRATION=True
diff --git a/poetry.lock b/poetry.lock
index 24e1c655c5..21aabe711d 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -465,14 +465,6 @@ version = "1.0.1"
[package.dependencies]
beautifulsoup4 = "*"
-[[package]]
-category = "main"
-description = "Use Cache URLs in your Django application."
-name = "django-cache-url"
-optional = false
-python-versions = "*"
-version = "3.0.0"
-
[[package]]
category = "main"
description = "Provides a country field for Django models."
@@ -2276,7 +2268,7 @@ docs = ["sphinx", "jaraco.packaging (>=3.2)", "rst.linker (>=1.9)"]
testing = ["pathlib2", "contextlib2", "unittest2"]
[metadata]
-content-hash = "055ed0b43d81ca92b6b73e232754ef093c25d59cb946937efeb1d7db80db18ad"
+content-hash = "08a8caa3d6012e766e8127d84f1cb61952258e205e7aaa486039c6299579b446"
python-versions = "~3.8"
[metadata.files]
@@ -2491,10 +2483,6 @@ django-babel = [
django-bootstrap4 = [
{file = "django-bootstrap4-1.0.1.tar.gz", hash = "sha256:3da770392819267eda2f774bcf832460af00db21089b94caf4df94be8a48c48c"},
]
-django-cache-url = [
- {file = "django-cache-url-3.0.0.tar.gz", hash = "sha256:235950e2d7cb16164082167c2974301e2f0fb2313d40bfacc9d24f5b09c3514b"},
- {file = "django_cache_url-3.0.0-py2.py3-none-any.whl", hash = "sha256:964120787dc80e568a355385a3880a19f2f00219c251903956f3137d1583d097"},
-]
django-countries = [
{file = "django-countries-5.5.tar.gz", hash = "sha256:1cefad9ec804d6a0318b91c5394b5aef00336755928f44d0a6420507719d65c8"},
{file = "django_countries-5.5-py2.py3-none-any.whl", hash = "sha256:22e96236101783cfe5222ef5174972242a7e8176336d119a4dc111aedce35897"},
diff --git a/pyproject.toml b/pyproject.toml
index a605448ee1..873f9f2760 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -23,7 +23,6 @@ dj-email-url = "^0"
django = "~2.2"
django-babel = "^0"
django-bootstrap4 = "~1"
-django-cache-url = "^3.0"
django-countries = "^5.3"
django-filter = "^2.2"
django-graphql-jwt = "<=0.2.1" # https://github.com/mirumee/saleor/issues/4652
diff --git a/requirements.txt b/requirements.txt
index 2c51bd8ea8..e93530a1af 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -102,9 +102,6 @@ django-babel==0.6.2 \
--hash=sha256:b62084a6f0cbf2e7af719bd129abfe54608a52645c0677aff5a728f586873af7
django-bootstrap4==1.0.1 \
--hash=sha256:3da770392819267eda2f774bcf832460af00db21089b94caf4df94be8a48c48c
-django-cache-url==3.0.0 \
- --hash=sha256:235950e2d7cb16164082167c2974301e2f0fb2313d40bfacc9d24f5b09c3514b \
- --hash=sha256:964120787dc80e568a355385a3880a19f2f00219c251903956f3137d1583d097
django-countries==5.5 \
--hash=sha256:1cefad9ec804d6a0318b91c5394b5aef00336755928f44d0a6420507719d65c8 \
--hash=sha256:22e96236101783cfe5222ef5174972242a7e8176336d119a4dc111aedce35897
diff --git a/requirements_dev.txt b/requirements_dev.txt
index c163ec1e80..d5dbb8699b 100644
--- a/requirements_dev.txt
+++ b/requirements_dev.txt
@@ -171,9 +171,6 @@ django-babel==0.6.2 \
--hash=sha256:b62084a6f0cbf2e7af719bd129abfe54608a52645c0677aff5a728f586873af7
django-bootstrap4==1.0.1 \
--hash=sha256:3da770392819267eda2f774bcf832460af00db21089b94caf4df94be8a48c48c
-django-cache-url==3.0.0 \
- --hash=sha256:235950e2d7cb16164082167c2974301e2f0fb2313d40bfacc9d24f5b09c3514b \
- --hash=sha256:964120787dc80e568a355385a3880a19f2f00219c251903956f3137d1583d097
django-countries==5.5 \
--hash=sha256:1cefad9ec804d6a0318b91c5394b5aef00336755928f44d0a6420507719d65c8 \
--hash=sha256:22e96236101783cfe5222ef5174972242a7e8176336d119a4dc111aedce35897
diff --git a/saleor/core/__init__.py b/saleor/core/__init__.py
index e2d512343a..e69de29bb2 100644
--- a/saleor/core/__init__.py
+++ b/saleor/core/__init__.py
@@ -1,28 +0,0 @@
-from django.conf import settings
-from django.core.checks import Warning, register
-
-TOKEN_PATTERN = (
- "(?P<token>[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}" "-[0-9a-z]{12})"
-)
-
-
-@register()
-def check_session_caching(app_configs, **kwargs): # pragma: no cover
- errors = []
- cached_engines = {
- "django.contrib.sessions.backends.cache",
- "django.contrib.sessions.backends.cached_db",
- }
- if (
- "locmem" in settings.CACHES["default"]["BACKEND"]
- and settings.SESSION_ENGINE in cached_engines
- ):
- errors.append(
- Warning(
- "Session caching cannot work with locmem backend",
- "User sessions need to be globally shared, use a cache server"
- " like Redis.",
- "saleor.W001",
- )
- )
- return errors
diff --git a/saleor/settings.py b/saleor/settings.py
index b50bf6a255..5f709e4a02 100644
--- a/saleor/settings.py
+++ b/saleor/settings.py
@@ -4,7 +4,6 @@ import warnings
import dj_database_url
import dj_email_url
-import django_cache_url
import sentry_sdk
from django.contrib.messages import constants as messages
from django.utils.translation import gettext_lazy as _, pgettext_lazy
@@ -47,12 +46,6 @@ ALLOWED_CLIENT_HOSTS = get_list(
INTERNAL_IPS = get_list(os.environ.get("INTERNAL_IPS", "127.0.0.1"))
-# Some cloud providers (Heroku) export REDIS_URL variable instead of CACHE_URL
-REDIS_URL = os.environ.get("REDIS_URL")
-if REDIS_URL:
- CACHE_URL = os.environ.setdefault("CACHE_URL", REDIS_URL)
-CACHES = {"default": django_cache_url.config()}
-
DATABASES = {
"default": dj_database_url.config(
default="postgres://saleor:saleor@localhost:5432/saleor", conn_max_age=600
@@ -175,9 +168,6 @@ loaders = [
"django.template.loaders.app_directories.Loader",
]
-if not DEBUG:
- loaders = [("django.template.loaders.cached.Loader", loaders)]
-
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
@@ -411,11 +401,6 @@ PAYMENT_MODEL = "order.Payment"
SESSION_SERIALIZER = "django.contrib.sessions.serializers.JSONSerializer"
-# Do not use cached session if locmem cache backend is used but fallback to use
-# default django.contrib.sessions.backends.db instead
-if not CACHES["default"]["BACKEND"].endswith("LocMemCache"):
- SESSION_ENGINE = "django.contrib.sessions.backends.cached_db"
-
MESSAGE_TAGS = {messages.ERROR: "danger"}
LOW_STOCK_THRESHOLD = 10
@@ -474,8 +459,6 @@ elif GS_MEDIA_BUCKET_NAME:
DEFAULT_FILE_STORAGE = "saleor.core.storages.GCSMediaStorage"
THUMBNAIL_DEFAULT_STORAGE = DEFAULT_FILE_STORAGE
-MESSAGE_STORAGE = "django.contrib.messages.storage.session.SessionStorage"
-
VERSATILEIMAGEFIELD_RENDITION_KEY_SETS = {
"products": [
("product_gallery", "thumbnail__540x540"),