Permalink
Browse files

added possibility to create a filesystem cache

  • Loading branch information...
zolex committed Sep 9, 2012
1 parent 723a304 commit 6b36b585beae8c02e509a9b17e8e136d033e324d
View
@@ -26,6 +26,10 @@
'array' => array(
'class' => 'Doctrine\Common\Cache\ArrayCache',
),
+ 'filesystem' => array(
+ 'class' => 'Doctrine\Common\Cache\FilesystemCache',
+ 'directory' => 'data/DoctrineModule/cache',
+ ),
'memcache' => array(
'class' => 'Doctrine\Common\Cache\MemcacheCache',
'instance' => 'my_memcache_alias',
@@ -88,6 +88,7 @@ public function getServiceConfig()
'doctrine.cli' => 'DoctrineModule\Service\CliFactory',
'doctrine.cache.apc' => new CacheFactory('apc'),
'doctrine.cache.array' => new CacheFactory('array'),
+ 'doctrine.cache.filesystem' => new CacheFactory('filesystem'),
'doctrine.cache.memcache' => new CacheFactory('memcache'),
'doctrine.cache.memcached' => new CacheFactory('memcached'),
'doctrine.cache.redis' => new CacheFactory('redis'),
@@ -43,6 +43,13 @@ class Cache extends AbstractOptions
* @var string
*/
protected $namespace = '';
+
+ /**
+ * Directory for file-based caching
+ *
+ * @var string
+ */
+ protected $directory;
/**
* Key to use for fetching the memcache, memcached, or redis instance from
@@ -108,4 +115,24 @@ public function getNamespace()
{
return $this->namespace;
}
+
+
+ /**
+ * @param string $directory
+ * @return self
+ */
+ public function setDirectory($directory)
+ {
+ $this->directory = $directory;
+
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getDirectory()
+ {
+ return $this->directory;
+ }
}
@@ -50,7 +50,11 @@ public function createService(ServiceLocatorInterface $sl)
throw new RuntimeException('Cache must have a class name to instantiate');
}
- $cache = new $class;
+ if ($class == 'Doctrine\Common\Cache\FilesystemCache') {
+ $cache = new $class($options->getDirectory());
+ } else {
+ $cache = new $class;
+ }
if ($cache instanceof MemcacheCache) {
/* @var $cache MemcacheCache */

0 comments on commit 6b36b58

Please sign in to comment.