Exemplo n.º 1
0
 def _wrap(self, method, *args, **kwargs):
     """对执行的命令进行验证
     Args:
         method: redis的方法
     """
     LOG.debug("redis adapter execute method:%s, args=%s, kwargs=%s", method, args, kwargs)
     try:
         key = args[0]
     except IndexError:
         raise ValueError('method %s requires a key param as the first argument' % method)
     if method.upper() in NOT_SUPPORT_COMMANDS:
         LOG.error('%s is not supported by codis', method)
         raise NotSupportCommandError('method %s is not supported by codis, key=%s' % (method, key))
     codis_func = getattr(self.api, method)
     return codis_func(*args, **kwargs)
Exemplo n.º 2
0
 def _wrap(self, method, *args, **kwargs):
     '''打包pipeline的方法
     Args:
         method: pipeline要执行的方法
         args: pipeline执行方法的参数
         kwargs: pipeline字典参数
     '''
     LOG.debug("pipeline execute method:%s, args=%s, kwargs=%s", method, args, kwargs)
     try:
         key = args[0]
     except:
         raise ValueError("'%s' requires a key param as the first argument" % method)
     if not self.transaction and method.upper() in NOT_SUPPORT_COMMANDS:
         LOG.error('%s is not supported by codis', method)
         raise NotSupportCommandError('method %s is not supported by codis, key=%s' % (method, key))
     # 执行codis
     f = getattr(self.codis_pipeline, method)
     f(*args, **kwargs)
Exemplo n.º 3
0
 def _wrap(self, method, *args, **kwargs):
     """对执行的命令进行验证
     Args:
         method: redis的方法
     """
     LOG.debug("redis adapter execute method:%s, args=%s, kwargs=%s",
               method, args, kwargs)
     try:
         key = args[0]
     except IndexError:
         raise ValueError(
             'method %s requires a key param as the first argument' %
             method)
     if method.upper() in NOT_SUPPORT_COMMANDS:
         LOG.error('%s is not supported by codis', method)
         raise NotSupportCommandError(
             'method %s is not supported by codis, key=%s' % (method, key))
     codis_func = getattr(self.api, method)
     return codis_func(*args, **kwargs)
Exemplo n.º 4
0
 def _wrap(self, method, *args, **kwargs):
     '''打包pipeline的方法
     Args:
         method: pipeline要执行的方法
         args: pipeline执行方法的参数
         kwargs: pipeline字典参数
     '''
     LOG.debug("pipeline execute method:%s, args=%s, kwargs=%s", method,
               args, kwargs)
     try:
         key = args[0]
     except:
         raise ValueError(
             "'%s' requires a key param as the first argument" % method)
     if not self.transaction and method.upper() in NOT_SUPPORT_COMMANDS:
         LOG.error('%s is not supported by codis', method)
         raise NotSupportCommandError(
             'method %s is not supported by codis, key=%s' % (method, key))
     # 执行codis
     f = getattr(self.codis_pipeline, method)
     f(*args, **kwargs)
Exemplo n.º 5
0
 def execute(self):
     '''提交pipeline执行
     '''
     LOG.debug("pipeline execute flag")
     return self.codis_pipeline.execute()
Exemplo n.º 6
0
 def __getattr__(self, method):
     """用于适配未定义的redis client的函数
     """
     LOG.debug("in __getattr__ method")
     return functools.partial(self._wrap, method)
Exemplo n.º 7
0
 def execute(self):
     '''提交pipeline执行
     '''
     LOG.debug("pipeline execute flag")
     return self.codis_pipeline.execute()
Exemplo n.º 8
0
 def __getattr__(self, method):
     """用于适配未定义的redis client的函数
     """
     LOG.debug("in __getattr__ method")
     return functools.partial(self._wrap, method)