-
Notifications
You must be signed in to change notification settings - Fork 20
Django 1.6 with Redis Cloud
Rodrigo Ancavil del Pino edited this page Jan 17, 2014
·
2 revisions
If you want or need Redis.IO in your Django application,m you can use Redis-Cloud.
First, you need create your first database in redis-cloud site. Here will be created the next URL:
Endpoint: YOUR_REDISCLOUD_HOSTNAME:YOUR_REDISCLOUD_DB_PORT
For the use of Redis with Django, you need install additional packages:
- django-redis-cache
- hiredis
You only need configure:
rhc env set REDISCLOUD_URL=YOUR_REDISCLOUD_HOSTNAME --app djangoproj
rhc env set REDISCLOUD_PORT=YOUR_REDISCLOUD_DB_PORT --app djangoproj
rhc env set REDISCLOUD_PASSWORD=YOUR_REDISCLOUD_DB_PASS --app djangoproj
Then make:
git push
For more details, see the settings.py file where redis-cloud is configurated:
Here, the settings.py file uses the environ variables previously configurated
# If you want configure the REDISCLOUD
if 'REDISCLOUD_URL' in os.environ and 'REDISCLOUD_PORT' in os.environ and
'REDISCLOUD_PASSWORD' in os.environ:
redis_server = os.environ['REDISCLOUD_URL']
redis_port = os.environ['REDISCLOUD_PORT']
redis_password = os.environ['REDISCLOUD_PASSWORD']
CACHES = {
'default' : {
'BACKEND' : 'redis_cache.RedisCache',
'LOCATION' : '%s:%d'%(redis_server,int(redis_port)),
'OPTIONS' : {
'DB':0,
'PARSER_CLASS' : 'redis.connection.HiredisParser',
'PASSWORD' : redis_password,
}
}
}
MIDDLEWARE_CLASSES = ('django.middleware.cache.UpdateCacheMiddleware',) +
MIDDLEWARE_CLASSES +
('django.middleware.cache.FetchFromCacheMiddleware',)