PHPDaemon\Clients\Memcache\Pool::replace PHP Method

replace() public method

Replaces the key
public replace ( string $key, string $value, integer $exp, callable $onResponse = null ) : void
$key string Key
$value string Value
$exp integer Lifetime in seconds (0 - immortal)
$onResponse callable Callback called when the request complete
return void
    public function replace($key, $value, $exp = 0, $onResponse = null)
    {
        $this->getConnectionByKey($key, function ($conn) use($key, $value, $exp, $onResponse) {
            if (!$conn->connected) {
                return;
            }
            if ($onResponse !== null) {
                $conn->onResponse->push($onResponse);
                $conn->checkFree();
            }
            $conn->writeln('replace ' . $this->config->prefix->value . $key . ' 0 ' . $exp . ' ' . mb_orig_strlen($value) . ($onResponse === null ? ' noreply' : '') . "\r\n" . $value);
        });
    }