diff --git a/.env.example b/.env.example index 7ac92721..cb0488d5 100644 --- a/.env.example +++ b/.env.example @@ -13,3 +13,5 @@ AWS_S3_CUSTOM_DOMAIN="" DJANGO_GOOGLE_OAUTH2_CLIENT_ID="" DJANGO_GOOGLE_OAUTH2_CLIENT_SECRET="" DJANGO_GOOGLE_OAUTH2_PROJECT_ID="" + +REDIS_URI=redis:6379 diff --git a/config/django/base.py b/config/django/base.py index f92f450f..06cd20af 100644 --- a/config/django/base.py +++ b/config/django/base.py @@ -182,6 +182,7 @@ from config.settings.jwt import * # noqa from config.settings.sentry import * # noqa from config.settings.sessions import * # noqa +from config.settings.cache import * # noqa from config.settings.debug_toolbar.settings import * # noqa from config.settings.debug_toolbar.setup import DebugToolbarSetup # noqa diff --git a/config/settings/cache.py b/config/settings/cache.py new file mode 100644 index 00000000..cecd9763 --- /dev/null +++ b/config/settings/cache.py @@ -0,0 +1,10 @@ +from config.env import env + +REDIS_URI = env("REDIS_URI", default="127.0.0.1:6379") + +CACHES = { + "default": { + "BACKEND": "django_redis.cache.RedisCache", + "LOCATION": f"redis://{REDIS_URI}/cache", + } +} diff --git a/docker-compose.yml b/docker-compose.yml index ad824de6..7ab5696b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,6 +17,10 @@ services: timeout: 30s retries: 3 + redis: + image: "redis:alpine" + restart: always + django: build: context: . @@ -32,6 +36,7 @@ services: depends_on: - db - rabbitmq + - redis restart: on-failure celery: @@ -47,6 +52,7 @@ services: depends_on: - db - rabbitmq + - redis restart: on-failure beats: @@ -62,4 +68,5 @@ services: depends_on: - db - rabbitmq + - redis restart: on-failure diff --git a/requirements/base.txt b/requirements/base.txt index 7421faec..6e3ffee9 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -13,6 +13,7 @@ django-filter==23.2 django-extensions==3.2.1 django-cors-headers==4.1.0 django-storages==1.13.1 +django-redis==5.4.0 drf-jwt==1.19.2 @@ -30,4 +31,4 @@ google-auth-httplib2==0.1.0 google-auth-oauthlib==1.0.0 pyotp==2.8.0 -qrcode==7.4.2 \ No newline at end of file +qrcode==7.4.2