本文整理匯總了Python中redis.client.Redis.from_url方法的典型用法代碼示例。如果您正苦於以下問題:Python Redis.from_url方法的具體用法?Python Redis.from_url怎麽用?Python Redis.from_url使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類redis.client.Redis
的用法示例。
在下文中一共展示了Redis.from_url方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: from_url
# 需要導入模塊: from redis.client import Redis [as 別名]
# 或者: from redis.client.Redis import from_url [as 別名]
def from_url(url, db=None, **kwargs):
"""Returns an active Redis client generated from the given database URL.
Will attempt to extract the database id from the path url fragment, if
none is provided.
"""
return Redis.from_url(url, db, **kwargs)
示例2: __init__
# 需要導入模塊: from redis.client import Redis [as 別名]
# 或者: from redis.client.Redis import from_url [as 別名]
def __init__(self, urls, **settings):
"""
Args:
urls: list of connection urls for `redis.client.StrictRedis#from_url`.
settings: additional settings for redis client.
Attributes:
mapping (dict): maintain the connection url & corresponding Redis client mapping.
sharding: `tornext.sharding.Sharding` instance for dispatching requests.
"""
self.sharding = Sharding(urls)
self.mapping = dict([(url, Redis.from_url(url)) for url in urls])