Skip to content

Commit

Permalink
Merge pull request #109 from alorence/develop
Browse files Browse the repository at this point in the history
Update DB selection syntax for Redis cache urls
  • Loading branch information
joke2k authored Apr 13, 2017
2 parents e92fddd + a4b38a2 commit 76aa880
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ This is your `settings.py` file before you have installed **django-environ**
},
'redis': {
'BACKEND': 'django_redis.cache.RedisCache',
'LOCATION': '127.0.0.1:6379:1',
'LOCATION': '127.0.0.1:6379/1',
'OPTIONS': {
'CLIENT_CLASS': 'django_redis.client.DefaultClient',
'PASSWORD': 'redis-githubbed-password',
Expand Down Expand Up @@ -116,7 +116,7 @@ Create a ``.env`` file:
DATABASE_URL=psql://urser:un-githubbedpassword@127.0.0.1:8458/database
# SQLITE_URL=sqlite:///my-local-sqlite.db
CACHE_URL=memcache://127.0.0.1:11211,127.0.0.1:11212,127.0.0.1:11213
REDIS_URL=rediscache://127.0.0.1:6379:1?client_class=django_redis.client.DefaultClient&password=redis-un-githubbed-password
REDIS_URL=rediscache://127.0.0.1:6379/1?client_class=django_redis.client.DefaultClient&password=redis-un-githubbed-password
How to install
Expand Down
8 changes: 4 additions & 4 deletions environ/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class BaseTests(unittest.TestCase):
ORACLE_TNS = 'oracle://user:password@sid/'
ORACLE = 'oracle://user:password@host:1521/sid'
MEMCACHE = 'memcache://127.0.0.1:11211'
REDIS = 'rediscache://127.0.0.1:6379:1?client_class=django_redis.client.DefaultClient&password=secret'
REDIS = 'rediscache://127.0.0.1:6379/1?client_class=django_redis.client.DefaultClient&password=secret'
EMAIL = 'smtps://user@domain.com:password@smtp.example.com:587'
JSON = dict(one='bar', two=2, three=33.44)
DICT = dict(foo='bar', test='on')
Expand Down Expand Up @@ -208,7 +208,7 @@ def test_cache_url_value(self):

redis_config = self.env.cache_url('CACHE_REDIS')
self.assertEqual(redis_config['BACKEND'], 'django_redis.cache.RedisCache')
self.assertEqual(redis_config['LOCATION'], 'redis://127.0.0.1:6379:1')
self.assertEqual(redis_config['LOCATION'], 'redis://127.0.0.1:6379/1')
self.assertEqual(redis_config['OPTIONS'], {
'CLIENT_CLASS': 'django_redis.client.DefaultClient',
'PASSWORD': 'secret',
Expand Down Expand Up @@ -439,11 +439,11 @@ def test_dummycache_parsing(self):
self.assertEqual(url['LOCATION'], '')

def test_redis_parsing(self):
url = 'rediscache://127.0.0.1:6379:1?client_class=django_redis.client.DefaultClient&password=secret'
url = 'rediscache://127.0.0.1:6379/1?client_class=django_redis.client.DefaultClient&password=secret'
url = Env.cache_url_config(url)

self.assertEqual(url['BACKEND'], REDIS_DRIVER)
self.assertEqual(url['LOCATION'], 'redis://127.0.0.1:6379:1')
self.assertEqual(url['LOCATION'], 'redis://127.0.0.1:6379/1')
self.assertEqual(url['OPTIONS'], {
'CLIENT_CLASS': 'django_redis.client.DefaultClient',
'PASSWORD': 'secret',
Expand Down
2 changes: 1 addition & 1 deletion environ/test_env.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ BOOL_FALSE_VAR2=False
DATABASE_MYSQL_URL=mysql://bea6eb0:69772142@us-cdbr-east.cleardb.com/heroku_97681?reconnect=true
DATABASE_MYSQL_GIS_URL=mysqlgis://user:password@127.0.0.1/some_database
CACHE_URL=memcache://127.0.0.1:11211
CACHE_REDIS=rediscache://127.0.0.1:6379:1?client_class=django_redis.client.DefaultClient&password=secret
CACHE_REDIS=rediscache://127.0.0.1:6379/1?client_class=django_redis.client.DefaultClient&password=secret
EMAIL_URL=smtps://user@domain.com:password@smtp.example.com:587
URL_VAR=http://www.google.com/
PATH_VAR=/home/dev
Expand Down

0 comments on commit 76aa880

Please sign in to comment.