public function setDirectory($directory)
    {
        if (!is_dir($directory) && !is_writable($directory)) {
            throw new FileCacheException(
                sprintf('The directory "%s" is not directory and not writable', $directory)
            );
        }

        if (is_null($directory) && !$this->getFilesystem()->mkdir($directory, 0777, true)) {
            throw new FileCacheException(
                sprintf('The directory "%s" not be null and directory not be created')
            );
        }

        $this->directory = realpath($directory);
    }