示例#1
0
 def __init__(self,
              host=None,
              port=6379,
              db=0,
              password=None,
              sentinels=None,
              service_name=None,
              decode_responses=True,
              socket_timeout=None,
              log=None,
              *args,
              **kwargs):
     if sentinels:
         sentinel = Sentinel(sentinels=sentinels)
         master = sentinel.discover_master(service_name=service_name)
         host, port = master
     self.server = {
         'host': host,
         'port': port,
         'db': db,
         'password': password,
         'decode_responses': decode_responses,
         'socket_timeout': socket_timeout
     }
     self.log = log if log else SimpleLog()
     self.pool = ConnectionPool(*args, **self.server, **kwargs)
     Redis.__init__(self, connection_pool=self.pool)
     # Redis.__init__(self, *args, **self.server, **kwargs)
     self.cache_result = {}
示例#2
0
 def __init__(self, key_prefix=None, error_sleep=1000, host='localhost', port=6379, db=0, password=None,
              socket_connect_timeout=1):
     self.key_prefix = key_prefix
     if key_prefix is not None:
         Redis.__init__(self, host, port, db, password=password, socket_connect_timeout=socket_connect_timeout)
     self.error_num = 0
     self.error_sleep = error_sleep
示例#3
0
 def __init__(self, postfix='backtest'):
     Redis.__init__(self,
                    host='redis',
                    port=6379,
                    db=0,
                    charset="utf-8",
                    decode_responses=True)
     pdebug5("Cache Pointing to: " + postfix)
     self.hash_postfix = postfix
示例#4
0
文件: db.py 项目: gitletian/flask_app
    def __new__(cls, db, *args, **kwargs):
        redis_conf = current_app.config["REDIS_CONF"]
        if not cls.redis[db]:
            # 支持多线程
            with cls._instance_lock:
                if not cls.redis[db]:
                    o = Redis.__new__(cls, *args)
                    # Redis.__init__(o, db=db, **cls.redis_conf)
                    Redis.__init__(o, db=db, **redis_conf)
                    cls.redis.insert(db, o)

        return cls.redis[db]
示例#5
0
    def __init__(self, *args, **kwargs):
        """
        Creates a new RedisBloom client.
        """
        Redis.__init__(self, *args, **kwargs)

        # Set the module commands' callbacks
        MODULE_CALLBACKS = {
            self.BF_RESERVE:
            bool_ok,
            #self.BF_ADD : spaceHolder,
            #self.BF_MADD : spaceHolder,
            #self.BF_INSERT : spaceHolder,
            #self.BF_EXISTS : spaceHolder,
            #self.BF_MEXISTS : spaceHolder,
            #self.BF_SCANDUMP : spaceHolder,
            #self.BF_LOADCHUNK : spaceHolder,
            self.CF_RESERVE:
            bool_ok,
            #self.CF_ADD : spaceHolder,
            #self.CF_ADDNX : spaceHolder,
            #self.CF_INSERT : spaceHolder,
            #self.CF_INSERTNX : spaceHolder,
            #self.CF_EXISTS : spaceHolder,
            #self.CF_DEL : spaceHolder,
            #self.CF_COUNT : spaceHolder,
            #self.CF_SCANDUMP : spaceHolder,
            #self.CF_LOADDUMP : spaceHolder,
            self.CMS_INITBYDIM:
            bool_ok,
            self.CMS_INITBYPROB:
            bool_ok,
            self.CMS_INCRBY:
            bool_ok,
            #self.CMS_QUERY : spaceHolder,
            self.CMS_MERGE:
            bool_ok,
            self.CMS_INFO:
            CMSInfo,
            self.TOPK_RESERVE:
            bool_ok,
            self.TOPK_ADD:
            parseToList,
            #self.TOPK_QUERY : spaceHolder,
            #self.TOPK_COUNT : spaceHolder,
            self.TOPK_LIST:
            parseToList,
            self.TOPK_INFO:
            TopKInfo,
        }
        for k, v in six.iteritems(MODULE_CALLBACKS):
            self.set_response_callback(k, v)
示例#6
0
 def __init__(self, *args, **kwargs):
     """
     Creates a new RedisTimeSeries client.
     """
     Redis.__init__(self, *args, **kwargs)
         
     # Set the module commands' callbacks
     MODULE_CALLBACKS = {
         self.CREATE_CMD : bool_ok,
         self.ADD_CMD : int_or_none,
         self.INCRBY_CMD : bool_ok,
         self.DECRBY_CMD : bool_ok,
         self.CREATERULE_CMD : bool_ok,
         self.DELETERULE_CMD : bool_ok,
         self.RANGE_CMD : parse_range,
         self.MRANGE_CMD : parse_m_range,
         self.GET_CMD : lambda x: (int(x[0]), float(x[1])),
         self.INFO_CMD : parse_info,
     }
     for k, v in six.iteritems(MODULE_CALLBACKS):
         self.set_response_callback(k, v)
示例#7
0
 def __init__(self, *args, **kwargs):
     """
     Creates a new RedisTimeSeries client.
     """
     Redis.__init__(self, *args, **kwargs)
         
     # Set the module commands' callbacks
     MODULE_CALLBACKS = {
         self.CREATE_CMD : bool_ok,
         self.ALTER_CMD : bool_ok, 
         self.CREATERULE_CMD : bool_ok,
         self.DELETERULE_CMD : bool_ok,
         self.RANGE_CMD : parse_range,
         self.MRANGE_CMD : parse_m_range,
         self.GET_CMD : lambda x: (int(x[0]), float(x[1])),
         self.MGET_CMD : parse_m_get,
         self.INFO_CMD : TSInfo,
         self.QUERYINDEX_CMD : parseToList,
     }
     for k in MODULE_CALLBACKS:
         self.set_response_callback(k, MODULE_CALLBACKS[k])
示例#8
0
 def __init__(self, host, port, db, pwd):
     Redis.__init__(self, host=host, port=port, db=db, password=pwd)
示例#9
0
文件: cache.py 项目: Deaseyy/Django
 def __init__(self, *args, **kwargs):
     _Redis.__init__(self, *args, **kwargs)
示例#10
0
 def __init__(self):
     Redis.__init__(self,host=Settings.Redis.Host,port=6379)
示例#11
0
文件: connector.py 项目: mpdevs/mplib
 def __init__(self, db=0, env="local"):
     Redis.__init__(self, db=db, decode_responses=True, **get_env(env))  # 自动连接redis
     self.expiration_time = 0  # 设置过期时间,单位秒
示例#12
0
文件: Handler.py 项目: drxbate/M1
 def __init__(self):
     Redis.__init__(self,host="10.8.0.1",port=6379,password="******")
示例#13
0
    def __init__(self, **kwargs):

        Redis.__init__(self, **kwargs)
示例#14
0
 def __init__(self, *args, **kwargs):
     Redis.__init__(self, *args, **kwargs)
     self.mfp = MockFP()
     self.callbacks = []
 def __init__(self, host, port, db, *args, **kwargs):
     Redis.__init__(self, host, port, db, *args, **kwargs)
     self._host = host
     self._port = port
     self._db = db
示例#16
0
 def __init__(self, *args, **kwargs):
     self.namespace = kwargs.pop('namespace')
     Redis.__init__(self, *args, **kwargs)
示例#17
0
 def __init__(self, host, port, db, *args, **kwargs):
     Redis.__init__(self, host, port, db, *args, **kwargs)
     self._host = host
     self._port = port
     self._db = db
示例#18
0
 def __init__(self, *args, **kwargs):
     self.namespace = kwargs.pop('namespace')
     Redis.__init__(self, *args, **kwargs)
示例#19
0
文件: sredis.py 项目: towi/dropyf2f
 def __init__(self, *v, **kw):
     _Redis.__init__(self, *v, **kw)
示例#20
0
文件: sredis.py 项目: towi/dropyf2f
 def __init__(self, *v, **kw):
     _Redis.__init__(self, *v, **kw)
示例#21
0
 def __init__(self, Settings, BoardCode):
     Redis.__init__(self,
                    host=Settings["REDIS"],
                    port=Settings["REDIS_PORT"],
                    password=Settings["REDIS_PASSWORD"],
                    db=BoardCode["dbid"])