Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add redis integration for cache #396

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions config/django/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions config/settings/cache.py
Original file line number Diff line number Diff line change
@@ -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",
}
}
7 changes: 7 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ services:
timeout: 30s
retries: 3

redis:
image: "redis:alpine"
restart: always

django:
build:
context: .
Expand All @@ -32,6 +36,7 @@ services:
depends_on:
- db
- rabbitmq
- redis
restart: on-failure

celery:
Expand All @@ -47,6 +52,7 @@ services:
depends_on:
- db
- rabbitmq
- redis
restart: on-failure

beats:
Expand All @@ -62,4 +68,5 @@ services:
depends_on:
- db
- rabbitmq
- redis
restart: on-failure
3 changes: 2 additions & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -30,4 +31,4 @@ google-auth-httplib2==0.1.0
google-auth-oauthlib==1.0.0

pyotp==2.8.0
qrcode==7.4.2
qrcode==7.4.2