Merge "Add dbid parameter to pools's uri based on redis"

This commit is contained in:
Zuul 2017-10-28 10:31:27 +00:00 committed by Gerrit Code Review
commit 5cded65dff
2 changed files with 11 additions and 1 deletions

View File

@ -27,6 +27,7 @@ from zaqar.storage.redis import options
REDIS_DEFAULT_PORT = 6379
SENTINEL_DEFAULT_PORT = 26379
DEFAULT_SOCKET_TIMEOUT = 0.1
DEFAULT_DBID = 0
STRATEGY_TCP = 1
STRATEGY_UNIX = 2
@ -59,6 +60,7 @@ class ConnectionURI(object):
self.strategy = None
self.socket_timeout = float(query_params.get('socket_timeout',
DEFAULT_SOCKET_TIMEOUT))
self.dbid = int(query_params.get('dbid', DEFAULT_DBID))
# TCP
self.port = None
@ -285,6 +287,7 @@ def _get_redis_client(driver):
return redis.StrictRedis(
host=connection_uri.hostname,
port=connection_uri.port,
db=connection_uri.dbid,
socket_timeout=connection_uri.socket_timeout)
else:
return redis.StrictRedis(

View File

@ -41,7 +41,14 @@ _COMMON_REDIS_OPTIONS = (
'forms, the "socket_timeout" option may be '
'specified in the query string. Its value is '
'given in seconds. If not provided, '
'"socket_timeout" defaults to 0.1 seconds.')),
'"socket_timeout" defaults to 0.1 seconds.'
'There are multiple database instances in redis '
'database, for example in the /etc/redis/redis.conf, '
'if the parameter is "database 16", there are 16 '
'database instances. By default, the data is stored '
'in db = 0 database, if you want to use db = 1 '
'database, you can use the following form: '
'"redis://host[:port][?dbid=1]".')),
cfg.IntOpt('max_reconnect_attempts', default=10,
deprecated_opts=[cfg.DeprecatedOpt(