Skip to content

Commit

Permalink
Support for memcached
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamgilbert committed Aug 11, 2015
1 parent 4673947 commit 0e32607
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
20 changes: 20 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,24 @@ $ docker run -d --name="sal" \
macadmins/sal:2.0.1
```

# Advanced usage

Sal supports the use of memcached for improving performance. It exects a linked memcached container and will use it if there is a container named ``memcached``:

``` bash
$ docker run -d \
--restart="always" \
--name="memcached" \
memcached:1.4.24

$ docker run -d --name="sal" \
-p 80:8000 \
--link postgres-sal:db \
--link memcached:memcached \
-e ADMIN_PASS=pass \
-e DB_NAME=sal \
-e DB_USER=admin \
-e DB_PASS=password \
--restart="always" \
macadmins/sal:2.0.1
```
11 changes: 11 additions & 0 deletions docker/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@
}
}

# Memcached
if os.environ.has_key('MEMCACHED_PORT_11211_TCP_ADDR'):
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': [
'%s:%s' % (os.environ['MEMCACHED_PORT_11211_TCP_ADDR'], os.environ['MEMCACHED_PORT_11211_TCP_PORT']),
]
}
}

# PG Database
if os.environ.has_key('DB_PORT_5432_TCP_ADDR'):
DATABASES = {
Expand Down
3 changes: 2 additions & 1 deletion setup/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ requests==2.5.0
six==1.9.0
urllib3==1.10
wsgiref==0.1.2
djangorestframework==3.1.3
djangorestframework==3.1.3
python-memcached==1.57

0 comments on commit 0e32607

Please sign in to comment.