doctrine/cache — pull request #30 by kamermans (2014-03-26 04:02:32+00:00)
Title: Added support for setting the default file and folder permissions

After lecturing my developers on not using `0777` file permissions, and then forcing them to use the `Doctrine\Cache` component (because I love it :) ), I have come to realize that it creates `0777` folders, and this behavior is not adjustable. The file permissions are determined by the current process umask as they are not explicitly set.

This PR allows you to set the default folder and file mode if you so choose. By default the existing behavior is used.

In my case, I would prefer `0770` for directories and `0660` for files. Here's how to do it with my PR:

```php
$cache = new FilesystemCache('/tmp/');
$cache->setDirectoryMode(0770);
$cache->setFileMode(0660);
```

The specific use case for me is that my developers are in the `www-data` group, which is the group that creates the cache files, and I want them to be able to delete the cache files if need be, but I do not want the cache files to be readable by any random user on the system.

I have also added a unit test to cover the file permissions. This test is skipped on Windows, since file permissions are not actually set (although `chmod` returns true and `fileperms` always returns `0644`).