Skip to content

Commit c30bcc3

Browse files
committed
Added doctrine filesystem cache
1 parent 34afeb7 commit c30bcc3

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
/*
4+
* This file is part of php-cache\adapter-bundle package.
5+
*
6+
* (c) 2015-2015 Aaron Scherer <[email protected]>, Tobias Nyholm <[email protected]>
7+
*
8+
* This source file is subject to the MIT license that is bundled
9+
* with this source code in the file LICENSE.
10+
*/
11+
12+
namespace Cache\AdapterBundle\Factory;
13+
14+
use Cache\Adapter\Doctrine\DoctrineCachePool;
15+
use Doctrine\Common\Cache\FilesystemCache;
16+
use Symfony\Component\OptionsResolver\OptionsResolver;
17+
18+
/**
19+
* @author Tobias Nyholm <[email protected]>
20+
*/
21+
class DoctrineFilesystemFactory extends AbstractDoctrineAdapterFactory
22+
{
23+
/**
24+
* {@inheritdoc}
25+
*/
26+
public function getAdapter(array $config)
27+
{
28+
$client = new FilesystemCache($config['directory'], $config['extension'], $config['umask']);
29+
30+
return new DoctrineCachePool($client);
31+
}
32+
33+
/**
34+
* {@inheritdoc}
35+
*/
36+
protected static function configureOptionResolver(OptionsResolver $resolver)
37+
{
38+
$resolver->setDefaults([
39+
'extension' => FilesystemCache::EXTENSION,
40+
'umask' => '0002',
41+
]);
42+
43+
$resolver->setRequired(['directory']);
44+
45+
$resolver->setAllowedTypes('directory', ['string']);
46+
$resolver->setAllowedTypes('extension', ['string']);
47+
$resolver->setAllowedTypes('umask', ['string', 'int']);
48+
}
49+
}

src/Resources/config/services.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ services:
1818

1919
cache.factory.doctrine_couchbase:
2020
class: Cache\AdapterBundle\Factory\DoctrineCouchbaseFactory
21+
cache.factory.doctrine_filesystem:
22+
class: Cache\AdapterBundle\Factory\DoctrineFilesystemFactory
2123
cache.factory.doctrine_memcached:
2224
class: Cache\AdapterBundle\Factory\DoctrineMemcachedFactory
2325
cache.factory.doctrine_memcache:

0 commit comments

Comments
 (0)