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


Python _compat.imap函数代码示例

本文整理汇总了Python中redis._compat.imap函数的典型用法代码示例。如果您正苦于以下问题:Python imap函数的具体用法?Python imap怎么用?Python imap使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: pack_command

    def pack_command(self, *args):
        "Pack a series of arguments into the Redis protocol"
        output = []
        # the client might have included 1 or more literal arguments in
        # the command name, e.g., 'CONFIG GET'. The Redis server expects these
        # arguments to be sent separately, so split the first argument
        # manually. All of these arguements get wrapped in the Token class
        # to prevent them from being encoded.
        command = args[0]
        if ' ' in command:
            args = tuple([Token(s) for s in command.split(' ')]) + args[1:]
        else:
            args = (Token(command),) + args[1:]

        buff = SYM_EMPTY.join(
            (SYM_STAR, b(str(len(args))), SYM_CRLF))

        for arg in imap(self.encode, args):
            # to avoid large string mallocs, chunk the command into the
            # output list if we're sending large values
            if len(buff) > self._buffer_cutoff or \
               len(arg) > self._buffer_cutoff:
                buff = SYM_EMPTY.join(
                    (buff, SYM_DOLLAR, b(str(len(arg))), SYM_CRLF))
                output.append(buff)
                output.append(arg)
                buff = SYM_CRLF
            else:
                buff = SYM_EMPTY.join((buff, SYM_DOLLAR, b(str(len(arg))),
                                       SYM_CRLF, arg, SYM_CRLF))
        output.append(buff)
        return output
开发者ID:joshowen,项目名称:redis-py,代码行数:32,代码来源:connection.py

示例2: pack_command

 def pack_command(self, *args):
     args_output = SYM_EMPTY.join([
         SYM_EMPTY.join((SYM_DOLLAR, b(str(len(k))), SYM_CRLF, k, SYM_CRLF))
         for k in imap(self.encode, args)])
     output = SYM_EMPTY.join(
         (SYM_STAR, b(str(len(args))), SYM_CRLF, args_output))
     return output
开发者ID:diaocow,项目名称:annotated_redis-py,代码行数:7,代码来源:connection.py

示例3: annotate_exception

 def annotate_exception(self, exception, number, command):
     """
     """
     cmd = unicode(' ').join(imap(unicode, command))
     msg = unicode('Command # {0} ({1}) of pipeline caused error: {2}').format(
         number, cmd, unicode(exception.args[0]))
     exception.args = (msg,) + exception.args[1:]
开发者ID:Grokzen,项目名称:redis-py-cluster,代码行数:7,代码来源:pipeline.py

示例4: pack_command

 def pack_command(self, *args):
     "Pack a series of arguments into a value Redis command"
     args_output = SYM_EMPTY.join([
         SYM_EMPTY.join((SYM_DOLLAR, b(str(len(k))), SYM_CRLF, k, SYM_CRLF))
         for k in imap(self.encode, args)])
     output = SYM_EMPTY.join(
         (SYM_STAR, b(str(len(args))), SYM_CRLF, args_output))
     return output
开发者ID:haandol,项目名称:redis-py,代码行数:8,代码来源:connection.py

示例5: pack_command

 def pack_command(self, *args):
     "Pack a series of arguments into a value Redis command"
     output = SYM_STAR + b(str(len(args))) + SYM_CRLF
     for enc_value in imap(self.encode, args):
         output += SYM_DOLLAR
         output += b(str(len(enc_value)))
         output += SYM_CRLF
         output += enc_value
         output += SYM_CRLF
     return output
开发者ID:CNCBASHER,项目名称:linuxcnc-1,代码行数:10,代码来源:connection.py

示例6: pack_command

 def pack_command(self, *args):
     "Pack a series of arguments into a value Redis command"
     output = BytesIO()
     output.write(SYM_STAR)
     output.write(b(str(len(args))))
     output.write(SYM_CRLF)
     for enc_value in imap(self.encode, args):
         output.write(SYM_DOLLAR)
         output.write(b(str(len(enc_value))))
         output.write(SYM_CRLF)
         output.write(enc_value)
         output.write(SYM_CRLF)
     return output.getvalue()
开发者ID:DHLabs,项目名称:keep_isn,代码行数:13,代码来源:connection.py

示例7: pack_command

    def pack_command(self, *args):
        output = []
        buff = SYM_EMPTY.join(
            (SYM_STAR, str(len(args)).encode(), SYM_CRLF))

        for k in imap(self.encoder.encode, args):
            if len(buff) > 6000 or len(k) > 6000:
                buff = SYM_EMPTY.join(
                    (buff, SYM_DOLLAR, str(len(k)).encode(), SYM_CRLF))
                output.append(buff)
                output.append(k)
                buff = SYM_CRLF
            else:
                buff = SYM_EMPTY.join((buff, SYM_DOLLAR, str(len(k)).encode(),
                                       SYM_CRLF, k, SYM_CRLF))
        output.append(buff)
        return output
开发者ID:C2python,项目名称:redis-py,代码行数:17,代码来源:command_packer_benchmark.py

示例8: pack_command

    def pack_command(self, *args):
        "Pack a series of arguments into a value Redis command"
        output = []
        buff = SYM_EMPTY.join(
            (SYM_STAR, b(str(len(args))), SYM_CRLF))

        for k in imap(self.encode, args):
            if len(buff) > 6000 or len(k) > 6000:
                buff = SYM_EMPTY.join(
                    (buff, SYM_DOLLAR, b(str(len(k))), SYM_CRLF))
                output.append(buff)
                output.append(k)
                buff = SYM_CRLF
            else:
                buff = SYM_EMPTY.join((buff, SYM_DOLLAR, b(str(len(k))),
                                       SYM_CRLF, k, SYM_CRLF))
        output.append(buff)
        return output
开发者ID:ccgillett,项目名称:redis-py,代码行数:18,代码来源:connection.py

示例9: subscribe

 def subscribe(self, *args, **kwargs):
     """
     Subscribe to channels. Channels supplied as keyword arguments expect
     a channel name as the key and a callable as the value. A channel's
     callable will be invoked automatically when a message is received on
     that channel rather than producing a message via ``listen()`` or
     ``get_message()``.
     """
     if args:
         args = list_or_args(args[0], args[1:])
     new_channels = {}
     new_channels.update(dict.fromkeys(imap(self.encode, args)))
     for channel, handler in iteritems(kwargs):
         new_channels[self.encode(channel)] = handler
     ret_val = self.execute_command('SUBSCRIBE', *iterkeys(new_channels))
     # update the channels dict AFTER we send the command. we don't want to
     # subscribe twice to these channels, once for the command and again
     # for the reconnection.
     self.channels.update(new_channels)
     return ret_val
开发者ID:katakumpo,项目名称:niceredis,代码行数:20,代码来源:pubsub.py

示例10: annotate_exception

 def annotate_exception(self, exception, number, command):
     cmd = unicode(' ').join(imap(unicode, command))
     msg = unicode('Command # %d (%s) of pipeline caused error: %s') % (
         number, cmd, unicode(exception.args[0]))
     exception.args = (msg,) + exception.args[1:]
开发者ID:huangfupeng,项目名称:redis-py-cluster,代码行数:5,代码来源:pipeline.py


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