Sha256: 89ad52fef6d3e9a195c0e30e55dae277c793f122ec441c6c608d51f1f1ea5e9c

Contents?: true

Size: 686 Bytes

Versions: 7

Compression:

Stored size: 686 Bytes

Contents

<?php

namespace Predis\Protocol\Text;

use Predis\Commands\ICommand;
use Predis\Protocol\ICommandSerializer;

class TextCommandSerializer implements ICommandSerializer {
    public function serialize(ICommand $command) {
        $commandId = $command->getId();
        $arguments = $command->getArguments();

        $cmdlen = strlen($commandId);
        $reqlen = count($arguments) + 1;

        $buffer = "*{$reqlen}\r\n\${$cmdlen}\r\n{$commandId}\r\n";
        for ($i = 0; $i < $reqlen - 1; $i++) {
            $argument = $arguments[$i];
            $arglen  = strlen($argument);
            $buffer .= "\${$arglen}\r\n{$argument}\r\n";
        }

        return $buffer;
    }
}

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
appstats-0.25.1 doc/benchmarks/Predis/Protocol/Text/TextCommandSerializer.php
appstats-0.25.0 doc/benchmarks/Predis/Protocol/Text/TextCommandSerializer.php
appstats-0.24.0 doc/benchmarks/Predis/Protocol/Text/TextCommandSerializer.php
appstats-0.23.5 doc/benchmarks/Predis/Protocol/Text/TextCommandSerializer.php
appstats-0.23.4 doc/benchmarks/Predis/Protocol/Text/TextCommandSerializer.php
appstats-0.23.3 doc/benchmarks/Predis/Protocol/Text/TextCommandSerializer.php
appstats-0.23.2 doc/benchmarks/Predis/Protocol/Text/TextCommandSerializer.php