diff options
author | Andy McCurdy <andy@andymccurdy.com> | 2014-05-11 11:39:35 -0700 |
---|---|---|
committer | Andy McCurdy <andy@andymccurdy.com> | 2014-05-11 11:39:35 -0700 |
commit | de01ed4960d1b6925860247b12ee17231207e81b (patch) | |
tree | ac6fa8407d34a143051644d01e8226a7e4c75c25 /redis/client.py | |
parent | 500e76ad836d24ea18e3e14a9ae1ae03a4cb6b71 (diff) | |
parent | 6d3473de519ef5d4ebbfd788fce6785905c27c37 (diff) | |
download | redis-py-de01ed4960d1b6925860247b12ee17231207e81b.tar.gz |
Merge branch 'pr/436'
Conflicts:
tests/test_connection_pool.py
Diffstat (limited to 'redis/client.py')
-rw-r--r-- | redis/client.py | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/redis/client.py b/redis/client.py index 1c167f5..dc89d39 100644 --- a/redis/client.py +++ b/redis/client.py @@ -6,9 +6,9 @@ import warnings import threading import time as mod_time from redis._compat import (b, basestring, bytes, imap, iteritems, iterkeys, - itervalues, izip, long, nativestr, urlparse, - unicode) -from redis.connection import ConnectionPool, UnixDomainSocketConnection + itervalues, izip, long, nativestr, unicode) +from redis.connection import (ConnectionPool, parse_url, + UnixDomainSocketConnection) from redis.exceptions import ( ConnectionError, DataError, @@ -373,27 +373,16 @@ class StrictRedis(object): For example:: redis://username:password@localhost:6379/0 + unix:///path/to/socket.sock - If ``db`` is None, this method will attempt to extract the database ID - from the URL path component. + If using a "redis" URL and ``db`` is None, this method will attempt to + extract the database ID from the URL path component. When using a + UNIX domain socket URL, ``db`` defaults to 0 if not specified. Any additional keyword arguments will be passed along to the Redis class's initializer. """ - url = urlparse(url) - - # We only support redis:// schemes. - assert url.scheme == 'redis' or not url.scheme - - # Extract the database ID from the path component if hasn't been given. - if db is None: - try: - db = int(url.path.replace('/', '')) - except (AttributeError, ValueError): - db = 0 - - return cls(host=url.hostname, port=int(url.port or 6379), db=db, - password=url.password, **kwargs) + return cls(**parse_url(url, db=db, **kwargs)) def __init__(self, host='localhost', port=6379, db=0, password=None, socket_timeout=None, |