protected function getDirectoryByNamespace($namespace, $create = true)
    {
        // Check if directory is already known and surely created and writable!
        if (!isset($this->directoriesByNamespace[$namespace])) {

            // Check for type of directory structure
            if ($this->isFlatDirectoryStructure() !== true) {
                $structure = explode(self::NAMESPACE_SEPARATOR, $namespace);
            } else {
                $structure = [$namespace];
            }

            $targetDirectory = $this->getDirectory().implode(DIRECTORY_SEPARATOR, $structure);

            // Check if not already created ...
            if ($create === true && file_exists($targetDirectory) === false) {

                // Check if base folder is writable
                if (is_writeable($this->getDirectory()) === false) {
                    throw new Doozr_Cache_Service_Exception(
                        sprintf('Directory: "%s". isn\'t writable. Check permissions and path.', $this->getDirectory())
                    );
                }

                $directory = $this->getDirectory();

                foreach ($structure as $node) {
                    if (file_exists($directory.$node) === false) {
                        if (!mkdir($directory.$node, 0755)) {
                            throw new Doozr_Cache_Service_Exception(
                                sprintf('Can\'t make directory "%s". Check permissions and path.', $directory)
                            );
                        }

                        // mach directory
                        $directory .= $node.DIRECTORY_SEPARATOR;
                    }
                }

                // Clears file status cache
                $this->clear();
            }

            $this->directoriesByNamespace[$namespace] = $targetDirectory.DIRECTORY_SEPARATOR;
        }

        return $this->directoriesByNamespace[$namespace];
    }