Skip to content

Commit 609faf3

Browse files
committed
Merge pull request #19 from Richard-NL/master
Filesystem cache
2 parents d95ccd7 + 4765361 commit 609faf3

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/Dflydev/Pimple/Provider/DoctrineOrm/DoctrineOrmServiceProvider.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Doctrine\Common\Cache\ApcCache;
1515
use Doctrine\Common\Cache\ArrayCache;
1616
use Doctrine\Common\Cache\CacheProvider;
17+
use Doctrine\Common\Cache\FilesystemCache;
1718
use Doctrine\Common\Cache\MemcacheCache;
1819
use Doctrine\Common\Cache\MemcachedCache;
1920
use Doctrine\Common\Cache\XcacheCache;
@@ -254,6 +255,13 @@ public function register(\Pimple $app)
254255
return new XcacheCache;
255256
});
256257

258+
$app['orm.cache.factory.filesystem'] = $app->protect(function($cacheOptions) {
259+
if (empty($cacheOptions['path'])) {
260+
throw new \RuntimeException('FilesystemCache path not defined');
261+
}
262+
return new FilesystemCache($cacheOptions['path']);
263+
});
264+
257265
$app['orm.cache.factory'] = $app->protect(function($driver, $cacheOptions) use ($app) {
258266
switch ($driver) {
259267
case 'array':
@@ -266,6 +274,8 @@ public function register(\Pimple $app)
266274
return $app['orm.cache.factory.memcache']($cacheOptions);
267275
case 'memcached':
268276
return $app['orm.cache.factory.memcached']($cacheOptions);
277+
case 'filesystem':
278+
return $app['orm.cache.factory.filesystem']($cacheOptions);
269279
default:
270280
throw new \RuntimeException("Unsupported cache type '$driver' specified");
271281
}

0 commit comments

Comments
 (0)