protected function createNamespace()
    {
        $dir = $this->getPath();
        if (! file_exists($dir) || ! is_dir($dir)) {
            set_error_handler(function () {
                throw new Exception('An error occurred.');
            }, E_WARNING);
            try {
                mkdir($dir, $this->dirPermissions, true);
            } catch (Exception $ex) {
                restore_error_handler();
                throw new RuntimeException(
                    sprintf('Failed to create cache directory "%s".', $dir)
                );
            }
            restore_error_handler();
        }
        if (! is_writable($dir)) {
            throw new RuntimeException(
                sprintf('The cache directory "%s" is not writable.', $dir)
            );
        }
        if (! is_readable($dir)) {
            throw new RuntimeException(
                sprintf('The cache directory "%s" is not readable.', $dir)
            );
        }
    }