Skip to content

Commit

Permalink
Use redis instead of memcached
Browse files Browse the repository at this point in the history
  • Loading branch information
Syriiin committed Jun 1, 2024
1 parent 8c61b47 commit 288c46b
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 21 deletions.
6 changes: 4 additions & 2 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ volumes:
prometheus-data:
grafana-data:
beatmaps:
redis-data:
cache-data:
difficalcy-cache-data:

secrets:
Expand All @@ -29,7 +29,9 @@ services:
- queue-data:/var/lib/rabbitmq:rw

cache:
image: memcached:1
image: redis:7
volumes:
- cache-data:/data

api:
build: .
Expand Down
4 changes: 2 additions & 2 deletions config/dev/django.env
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ POSTGRES_DB_PASSWORD="osuchan"
POSTGRES_DB_HOST="db"
POSTGRES_DB_PORT="5432"

MEMCACHED_HOST="cache"
MEMCACHED_PORT="11211"
REDIS_HOST="cache"
REDIS_PORT="6379"

CELERY_USER="osuchan"
CELERY_PASSWORD="osuchan"
Expand Down
11 changes: 7 additions & 4 deletions osuchan/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class EnvSettings(BaseSettings):
POSTGRES_DB_PASSWORD: str
POSTGRES_DB_HOST: str
POSTGRES_DB_PORT: str
MEMCACHED_HOST: str
MEMCACHED_PORT: str
REDIS_HOST: str
REDIS_PORT: str
CELERY_USER: str
CELERY_PASSWORD: str
CELERY_HOST: str
Expand Down Expand Up @@ -183,8 +183,11 @@ class EnvSettings(BaseSettings):

CACHES = {
"default": {
"BACKEND": "django_prometheus.cache.backends.memcached.PyMemcacheCache",
"LOCATION": f"{env_settings.MEMCACHED_HOST}:{env_settings.MEMCACHED_PORT}",
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": f"redis://{env_settings.REDIS_HOST}:{env_settings.REDIS_PORT}/0",
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
},
}
}

Expand Down
60 changes: 48 additions & 12 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ gunicorn = "^22.0.0"
httpx = "^0.27.0"
oppaipy = "^1.0.4"
psycopg2-binary = "^2.9.1"
pymemcache = "^4.0.0"
requests = "^2.25.1"
rosu-pp-py = "^1.0.0"
tqdm = "^4.64.0"
flower = "^2.0.0"
pydantic-settings = "^2.0.0"
django-prometheus = "^2.3.1"
django-redis = "^5.4.0"

[tool.poetry.group.dev.dependencies]
black = "^24.4.2"
Expand Down

0 comments on commit 288c46b

Please sign in to comment.