protected function writeFile(string $key, int $exp, $val)
    {
        // Write to temp file first to ensure atomicity. Use crc32 for speed
        $dir = $this->getFullDirectory();
        $this->checkDirectory($dir);
        $tmp = $dir . DIRECTORY_SEPARATOR . crc32($key) . '-' . uniqid('', true) . '.tmp';
        file_put_contents($tmp, '<?php $exp = ' . $exp . '; $val = ' . $val . ';', LOCK_EX);
        return rename($tmp, $this->filePath($key));
    }