Sha256: c433be1579908317a167d7beda5e2c9035d4d300dc83b5be1c7e44b5ec121210

Contents?: true

Size: 872 Bytes

Versions: 52

Compression:

Stored size: 872 Bytes

Contents

class Redis
  module Connection
    module CommandHelper

      COMMAND_DELIMITER = "\r\n"

      def build_command(args)
        command = []
        command << "*#{args.size}"

        args.each do |arg|
          arg = arg.to_s
          command << "$#{string_size arg}"
          command << arg
        end

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

    protected

      if "".respond_to?(:bytesize)
        def string_size(string)
          string.to_s.bytesize
        end
      else
        def string_size(string)
          string.to_s.size
        end
      end

      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

52 entries across 52 versions & 6 rubygems

Version Path
abaci-0.3.0 vendor/bundle/gems/redis-2.2.2/lib/redis/connection/command_helper.rb
classiccms-0.7.5 vendor/bundle/gems/redis-2.2.2/lib/redis/connection/command_helper.rb
classiccms-0.7.4 vendor/bundle/gems/redis-2.2.2/lib/redis/connection/command_helper.rb
classiccms-0.7.3 vendor/bundle/gems/redis-2.2.2/lib/redis/connection/command_helper.rb
classiccms-0.7.2 vendor/bundle/gems/redis-2.2.2/lib/redis/connection/command_helper.rb
classiccms-0.7.1 vendor/bundle/gems/redis-2.2.2/lib/redis/connection/command_helper.rb
classiccms-0.7.0 vendor/bundle/gems/redis-2.2.2/lib/redis/connection/command_helper.rb
classiccms-0.6.9 vendor/bundle/gems/redis-2.2.2/lib/redis/connection/command_helper.rb
classiccms-0.6.8 vendor/bundle/gems/redis-2.2.2/lib/redis/connection/command_helper.rb
classiccms-0.6.7 vendor/bundle/gems/redis-2.2.2/lib/redis/connection/command_helper.rb
classiccms-0.6.6 vendor/bundle/gems/redis-2.2.2/lib/redis/connection/command_helper.rb
classiccms-0.6.5 vendor/bundle/gems/redis-2.2.2/lib/redis/connection/command_helper.rb
classiccms-0.6.4 vendor/bundle/gems/redis-2.2.2/lib/redis/connection/command_helper.rb
classiccms-0.6.3 vendor/bundle/gems/redis-2.2.2/lib/redis/connection/command_helper.rb
classiccms-0.6.2 vendor/bundle/gems/redis-2.2.2/lib/redis/connection/command_helper.rb
classiccms-0.6.1 vendor/bundle/gems/redis-2.2.2/lib/redis/connection/command_helper.rb
classiccms-0.6.0 vendor/bundle/gems/redis-2.2.2/lib/redis/connection/command_helper.rb
classiccms-0.5.17 vendor/bundle/gems/redis-2.2.2/lib/redis/connection/command_helper.rb
classiccms-0.5.16 vendor/bundle/gems/redis-2.2.2/lib/redis/connection/command_helper.rb
classiccms-0.5.15 vendor/bundle/gems/redis-2.2.2/lib/redis/connection/command_helper.rb