public function set($key, $value, $ttl = null)
    {
        $this->ensureValidKey($key);
        if ($ttl !== null) {
            $restore = $this->innerEngine->getConfig('duration');
            $this->innerEngine->setConfig('duration', $ttl);
        }
        try {
            $result = $this->innerEngine->write($key, $value);

            return (bool)$result;
        } finally {
            if (isset($restore)) {
                $this->innerEngine->setConfig('duration', $restore);
            }
        }
    }