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

set() public method

Sets the key
public set ( 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 set($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('set ' . $this->config->prefix->value . $key . ' 0 ' . $exp . ' ' . mb_orig_strlen($value) . ($onResponse === null ? ' noreply' : '') . "\r\n" . $value);
        });
    }