php-react-memcached icon indicating copy to clipboard operation
php-react-memcached copied to clipboard

Incorrect read message

Open Logioniz opened this issue 6 years ago • 0 comments

Such code works wrong:

<?php

$loader = require __DIR__ . '/vendor/autoload.php';

$loop = React\EventLoop\Factory::create();

use \seregazhuk\React\Memcached\Factory;

$memcached = Factory::createClient($loop, '127.0.0.1:9003');

$memcached->set('key', "VALUE qwe 0 3\r\nqwe\r\nEND\r\nVALUE asd 0 3\r\asd\r\nEND\r\nVALUE zxc 0 3\r\zxc\r\nEND")
        ->then(function () use ($memcached) {
            return $memcached->get('key');
        })
        ->then(function ($data) use ($loop) {
            var_dump($data);
            $loop->stop();
        });

$loop->run();

From protocol specification:

Therefore, when a client retrieves data from a server, it must use the length of the data block (which it will be provided with) to determine where the data block ends, and not the fact that \r\n follows the end of the data block, even though it does.

Logioniz avatar Mar 27 '19 15:03 Logioniz