Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update DB selection syntax for Redis cache urls #109

Merged
merged 1 commit into from
Apr 13, 2017

Conversation

alorence
Copy link
Contributor

@alorence alorence commented Feb 7, 2017

Since version 0.4.1, it is now possible to correctly configure a Redis server as cache system for Django application using django-environ. Specifically, it is now possible to select the DB to use.

As described in django-redis documentation, the correct value for Redis LOCATION Url is redis://127.0.0.1:6379/1 for DB1, redis://127.0.0.1:6379/6 for DB6, etc.

In my tests, the syntax redis://127.0.0.1:6379:1 didn't work. It writes values to DB 0 by default, and in some case, raises an exception:

  [...]
  File "C:\Users\Antoine\.virtualenvs\xxx\lib\site-packages\django_redis\pool.py", line 114, in get_connection_pool
    pool = self.pool_cls.from_url(**cp_params)
  File "C:\Users\Antoine\.virtualenvs\xxx\lib\site-packages\redis\connection.py", line 813, in from_url
    'port': int(url.port or 6379),
  File "c:\python35-x64\Lib\urllib\parse.py", line 159, in port
    port = int(port, 10)
ValueError: invalid literal for int() with base 10: '6379:4'

This PR may fix the issue and help users to use the right syntax when declaring a Redis cache.

@coveralls
Copy link

coveralls commented Feb 7, 2017

Coverage Status

Coverage remained the same at 88.312% when pulling a4b38a2 on alorence:develop into 43d572f on joke2k:develop.

@joke2k joke2k merged commit 76aa880 into joke2k:develop Apr 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants