Skip to content

Commit

Permalink
add env variable for cache service connection
Browse files Browse the repository at this point in the history
  • Loading branch information
sgmdlt committed Oct 18, 2024
1 parent ba33747 commit 44d96f0
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ POSTGRES_HOST=
POSTGRES_PORT=
SENTRY_DSN=
DJANGO_SUPERUSER_PASSWORD='admin'
CACHE_LOCATION='memcached:11211'
CACHE_USERNAME=
CACHE_PASSWORD=
8 changes: 6 additions & 2 deletions config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,12 @@

CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.PyMemcacheCache',
'LOCATION': 'memcached:11211',
'BACKEND': 'django_bmemcached.memcached.BMemcached',
'LOCATION': os.environ.get('CACHE_LOCATION', '').split(','),
'OPTIONS': {
'username': os.environ.get('CACHE_USERNAME', ''),
'password': os.environ.get('CACHE_PASSWORD', '')
}
}
}

Expand Down
5 changes: 4 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ services:

ports:
- 5433:5432

memcached:
image: memcached:alpine
ports:
Expand All @@ -25,6 +25,9 @@ services:
POSTGRES_HOST: db
POSTGRES_USER: postgres
POSTGRES_DB: postgres
CACHE_LOCATION: memcached
CACHE_USERNAME:
CACHE_PASSWORD:
volumes:
- .:/usr/local/src/hexlet-friends
ports:
Expand Down
41 changes: 40 additions & 1 deletion poetry.lock

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

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ django-mathfilters = "^1.0.0"
django-filter = "^23.2"
sentry-sdk = "^1.29.2"
pymemcache = "^4.0.0"
django-bmemcached = "^0.3.0"

[tool.poetry.group.dev.dependencies]
Faker = "^13.15.1"
Expand Down

0 comments on commit 44d96f0

Please sign in to comment.