当前位置: 首页>>代码示例>>Python>>正文


Python client.StrictRedis方法代码示例

本文整理汇总了Python中redis.client.StrictRedis方法的典型用法代码示例。如果您正苦于以下问题:Python client.StrictRedis方法的具体用法?Python client.StrictRedis怎么用?Python client.StrictRedis使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在redis.client的用法示例。


在下文中一共展示了client.StrictRedis方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: slave_for

# 需要导入模块: from redis import client [as 别名]
# 或者: from redis.client import StrictRedis [as 别名]
def slave_for(self, service_name, redis_class=StrictRedis,
                  connection_pool_class=SentinelConnectionPool, **kwargs):
        """
        Returns redis client instance for the ``service_name`` slave(s).

        A SentinelConnectionPool class is used to retrive the slave's
        address before establishing a new connection.

        By default clients will be a redis.StrictRedis instance. Specify a
        different class to the ``redis_class`` argument if you desire
        something different.

        The ``connection_pool_class`` specifies the connection pool to use.
        The SentinelConnectionPool will be used by default.

        All other keyword arguments are merged with any connection_kwargs
        passed to this class and passed to the connection pool as keyword
        arguments to be used to initialize Redis connections.
        """
        kwargs['is_master'] = False
        connection_kwargs = dict(self.connection_kwargs)
        connection_kwargs.update(kwargs)
        return redis_class(connection_pool=connection_pool_class(
            service_name, self, **connection_kwargs)) 
开发者ID:leancloud,项目名称:satori,代码行数:26,代码来源:sentinel.py

示例2: __init__

# 需要导入模块: from redis import client [as 别名]
# 或者: from redis.client import StrictRedis [as 别名]
def __init__(self, sentinels, min_other_sentinels=0, sentinel_kwargs=None,
                 **connection_kwargs):
        # if sentinel_kwargs isn't defined, use the socket_* options from
        # connection_kwargs
        if sentinel_kwargs is None:
            sentinel_kwargs = dict([(k, v)
                                    for k, v in iteritems(connection_kwargs)
                                    if k.startswith('socket_')
                                    ])
        self.sentinel_kwargs = sentinel_kwargs

        self.sentinels = [StrictRedis(hostname, port, **self.sentinel_kwargs)
                          for hostname, port in sentinels]
        self.min_other_sentinels = min_other_sentinels
        self.connection_kwargs = connection_kwargs 
开发者ID:leancloud,项目名称:satori,代码行数:17,代码来源:sentinel.py

示例3: master_for

# 需要导入模块: from redis import client [as 别名]
# 或者: from redis.client import StrictRedis [as 别名]
def master_for(self, service_name, redis_class=StrictRedis,
                   connection_pool_class=SentinelConnectionPool, **kwargs):
        """
        Returns a redis client instance for the ``service_name`` master.

        A SentinelConnectionPool class is used to retrive the master's
        address before establishing a new connection.

        NOTE: If the master's address has changed, any cached connections to
        the old master are closed.

        By default clients will be a redis.StrictRedis instance. Specify a
        different class to the ``redis_class`` argument if you desire
        something different.

        The ``connection_pool_class`` specifies the connection pool to use.
        The SentinelConnectionPool will be used by default.

        All other keyword arguments are merged with any connection_kwargs
        passed to this class and passed to the connection pool as keyword
        arguments to be used to initialize Redis connections.
        """
        kwargs['is_master'] = True
        connection_kwargs = dict(self.connection_kwargs)
        connection_kwargs.update(kwargs)
        return redis_class(connection_pool=connection_pool_class(
            service_name, self, **connection_kwargs)) 
开发者ID:leancloud,项目名称:satori,代码行数:29,代码来源:sentinel.py

示例4: client

# 需要导入模块: from redis import client [as 别名]
# 或者: from redis.client import StrictRedis [as 别名]
def client(self):
        if self._client is None:
            decode = not six.PY2
            self._client = redis_client.StrictRedis(host=self.ip,
                                                    port=self.port,
                                                    decode_responses=decode)
        return self._client 
开发者ID:openstack,项目名称:dragonflow,代码行数:9,代码来源:redis_db_driver.py


注:本文中的redis.client.StrictRedis方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。