Merge pull request #258 from burhan/feature/redis-cache

adding redis support
This commit is contained in:
Saurabh Kumar 2015-07-21 07:23:26 +05:30
commit 613b91d71e
6 changed files with 21 additions and 19 deletions

View File

@ -45,6 +45,7 @@ Adam Dobrawy / @ad-m
Daniele Tricoli / @eriol
Harry Percival / @hjwp
Cullen Rhodes / @c-rhodes
Burhan Khalid / @burhan
Audrey Roy Greenfeld / @audreyr (and creator/maintainer of cookiecutter) *
Burhan Khalid / @burhan
Jannis Gebauer / @got_nil

View File

@ -16,7 +16,7 @@ For configuration purposes, the following table maps the '{{cookiecutter.project
======================================= =========================== ============================================== ======================================================================
Environment Variable Django Setting Development Default Production Default
======================================= =========================== ============================================== ======================================================================
DJANGO_CACHES CACHES (default) locmem memcached
DJANGO_CACHES CACHES (default) locmem redis
DJANGO_DATABASES DATABASES (default) See code See code
DJANGO_DEBUG DEBUG True False
DJANGO_SECRET_KEY SECRET_KEY CHANGEME!!! raises error
@ -170,8 +170,8 @@ Run these commands to deploy the project to Heroku:
heroku pg:backups schedule --at '02:00 America/Los_Angeles' DATABASE_URL
heroku pg:promote DATABASE_URL
heroku addons:create heroku-redis:hobby-dev
heroku addons:create mailgun
heroku addons:create memcachier:dev
heroku config:set DJANGO_SECRET_KEY=`openssl rand -base64 32`
heroku config:set DJANGO_SETTINGS_MODULE='config.settings.production'
@ -201,7 +201,7 @@ added just like in Heroku however you must ensure you have the relevant Dokku pl
cd /var/lib/dokku/plugins
git clone https://github.com/rlaneve/dokku-link.git link
git clone https://github.com/jezdez/dokku-memcached-plugin memcached
git clone https://github.com/luxifer/dokku-redis-plugin redis
git clone https://github.com/jezdez/dokku-postgres-plugin postgres
dokku plugins-install
@ -217,8 +217,8 @@ You can then deploy by running the following commands.
git remote add dokku dokku@yourservername.com:{{cookiecutter.repo_name}}
git push dokku master
ssh -t dokku@yourservername.com dokku memcached:create {{cookiecutter.repo_name}}-memcached
ssh -t dokku@yourservername.com dokku memcached:link {{cookiecutter.repo_name}}-memcached {{cookiecutter.repo_name}}
ssh -t dokku@yourservername.com dokku redis:create {{cookiecutter.repo_name}}-redis
ssh -t dokku@yourservername.com dokku redis:link {{cookiecutter.repo_name}}-redis {{cookiecutter.repo_name}}
ssh -t dokku@yourservername.com dokku postgres:create {{cookiecutter.repo_name}}-postgres
ssh -t dokku@yourservername.com dokku postgres:link {{cookiecutter.repo_name}}-postgres {{cookiecutter.repo_name}}
ssh -t dokku@yourservername.com dokku config:set {{cookiecutter.repo_name}} DJANGO_SECRET_KEY=RANDOM_SECRET_KEY_HERE

View File

@ -125,15 +125,17 @@ DATABASES['default'] = env.db("DATABASE_URL")
# CACHING
# ------------------------------------------------------------------------------
try:
# Only do this here because thanks to django-pylibmc-sasl and pylibmc
# memcacheify is painful to install on windows.
# See: https://github.com/rdegges/django-heroku-memcacheify
from memcacheify import memcacheify
CACHES = memcacheify()
except ImportError:
CACHES = {
'default': env.cache_url("DJANGO_CACHE_URL", default="memcache://127.0.0.1:11211"),
# Heroku URL does not pass the DB number, so we parse it in
CACHES = {
"default": {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "{0}/{1}".format(env.cache_url('REDIS_URL', default="redis://127.0.0.1:6379"), 0),
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
"IGNORE_EXCEPTIONS": True, # mimics memcache behavior.
# http://niwinz.github.io/django-redis/latest/#_memcached_exceptions_behavior
}
}
}
# Your production stuff: Below this line define 3rd party library settings

View File

@ -19,9 +19,6 @@ libfreetype6-dev
liblcms1-dev
libwebp-dev
##pylibmc
libmemcached-dev
libssl-dev
##django-extensions
graphviz-dev

View File

@ -1,5 +1,3 @@
# This file is here because many Platforms as a Service look for
# requirements.txt in the root directory of a project.
pylibmc==1.5.0
django-heroku-memcacheify==0.8
-r requirements/production.txt

View File

@ -34,6 +34,10 @@ django-autoslug==1.8.0
# Time zones support
pytz==2015.4
# Redis support
django-redis==4.2.0
redis>=2.10.0
{% if cookiecutter.use_celery == "y" %}
celery==3.1.18
{% endif %}