Skip to content

Commit

Permalink
cove_project: settings: Add memcached backend if not in DEBUG mode
Browse files Browse the repository at this point in the history
Add with defaults as suggested in Django documentation.

Related: open-contracting/cove-ocds#90
  • Loading branch information
michaelwood committed Oct 7, 2020
1 parent 3c926af commit de5e75c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# cove-oc4ids

## Production installation

We recommened deploying [Django using uWSGI](https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/uwsgi/) and [Apache http server using mod_proxy](https://uwsgi-docs.readthedocs.io/en/latest/Apache.html#mod-proxy-uwsgi)

### Caching

In non-dev or not DEBUG mode the default settings make use of a local memcached server. This backend requires an additional dependency of `python-memcached` as well as memcached server running. On debian based systems this can be installed with `apt install memcached`.

## Dev installation

git clone https://github.com/open-contracting/cove-oc4ids.git
Expand Down
13 changes: 13 additions & 0 deletions cove_project/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@


MIDDLEWARE = (
'django.middleware.cache.UpdateCacheMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
Expand All @@ -64,6 +65,7 @@
'django.middleware.security.SecurityMiddleware',
'dealer.contrib.django.Middleware',
'cove.middleware.CoveConfigCurrentApp',
'django.middleware.cache.FetchFromCacheMiddleware',
)


Expand Down Expand Up @@ -159,3 +161,14 @@
# https://github.com/open-contracting/deploy/issues/188
CSRF_COOKIE_NAME = 'oc4idscsrftoken'
SESSION_COOKIE_NAME = 'oc4idssessionid'

if not DEBUG:
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': '127.0.0.1:11211',
'OPTIONS': {
'server_max_value_length': 1024 * 1024 * 2,
}
}
}

0 comments on commit de5e75c

Please sign in to comment.