Sha256: 4e8f934221e3d2a4a4cd8cb10c4b525bcc88f3f6494ddc42dc9692788b74ecac

Contents?: true

Size: 875 Bytes

Versions: 34

Compression:

Stored size: 875 Bytes

Contents

class Redis
  module Connection
    module CommandHelper

      COMMAND_DELIMITER = "\r\n"

      def build_command(args)
        command = [nil]

        args.each do |i|
          if i.is_a? Array
            i.each do |j|
              j = j.to_s
              command << "$#{j.bytesize}"
              command << j
            end
          else
            i = i.to_s
            command << "$#{i.bytesize}"
            command << i
          end
        end

        command[0] = "*#{(command.length - 1) / 2}"

        # Trailing delimiter
        command << ""
        command.join(COMMAND_DELIMITER)
      end

    protected

      if defined?(Encoding::default_external)
        def encode(string)
          string.force_encoding(Encoding::default_external)
        end
      else
        def encode(string)
          string
        end
      end
    end
  end
end

Version data entries

34 entries across 33 versions & 10 rubygems

Version Path
finsync_redis-3.3.5 lib/redis/connection/command_helper.rb
redis-3.3.5 lib/redis/connection/command_helper.rb
logstash-filter-cache-redis-0.3.1 vendor/bundle/jruby/1.9/gems/redis-3.3.3/lib/redis/connection/command_helper.rb
logstash-filter-cache-redis-0.3.0 vendor/bundle/jruby/1.9/gems/redis-3.3.3/lib/redis/connection/command_helper.rb
logstash-filter-cache-redis-0.2.0 vendor/bundle/jruby/1.9/gems/redis-3.3.3/lib/redis/connection/command_helper.rb
logstash-filter-cache-redis-0.1.0 vendor/bundle/jruby/1.9/gems/redis-3.3.3/lib/redis/connection/command_helper.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/redis-3.3.3/lib/redis/connection/command_helper.rb
redis-3.3.3 lib/redis/connection/command_helper.rb
abaci-0.3.0 vendor/bundle/gems/redis-3.3.2/lib/redis/connection/command_helper.rb
abaci-0.3.0 vendor/bundle/gems/redis-3.3.1/lib/redis/connection/command_helper.rb
redis-3.3.2 lib/redis/connection/command_helper.rb
redis-3.3.1 lib/redis/connection/command_helper.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/redis-3.3.0/lib/redis/connection/command_helper.rb
redis-3.3.0 lib/redis/connection/command_helper.rb
discourse-redis-3.2.2 lib/redis/connection/command_helper.rb
redis-3.2.2 lib/redis/connection/command_helper.rb
redis-3.2.1 lib/redis/connection/command_helper.rb
redis-3.2.0 lib/redis/connection/command_helper.rb
redis-3.1.0 lib/redis/connection/command_helper.rb
redis-3.0.7 lib/redis/connection/command_helper.rb