Skip to content
This repository has been archived by the owner on Dec 5, 2017. It is now read-only.

Commit

Permalink
Merge pull request #14 from maxromanovsky/redis
Browse files Browse the repository at this point in the history
Added Redis support
  • Loading branch information
lsmith77 committed Aug 8, 2013
2 parents 5b92182 + 43d7ab8 commit 4e90369
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
18 changes: 18 additions & 0 deletions DependencyInjection/Compiler/ServiceCreationCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,24 @@ public function process(ContainerBuilder $container)

$service->addMethodCall('setMemcached', array(new Reference($memcachedId)));
break;
case 'redis':
if (empty($config['id'])) {
$redisHost = !empty($config['host']) ? $config['host'] : '%liip_doctrine_cache.redis_host%';
$redisPort = !empty($config['port']) ? $config['port'] : '%liip_doctrine_cache.redis_port%';
$redisTimeout = !empty($config['timeout']) ? $config['timeout'] : '%liip_doctrine_cache.redis_timeout%';
$redis = new Definition('Redis');
$redis->addMethodCall('connect', array(
$redisHost, $redisPort, $redisTimeout
));
$redis->setPublic(false);
$redisId = sprintf('liip_doctrine_cache.%s_redis_instance', $name);
$container->setDefinition($redisId, $redis);
} else {
$redisId = $config['id'];
}

$service->addMethodCall('setRedis', array(new Reference($redisId)));
break;
case 'file_system':
case 'php_file':
$directory = !empty($config['directory']) ? $config['directory'] : '%kernel.cache_dir%/doctrine/cache';
Expand Down
5 changes: 5 additions & 0 deletions Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
<parameter key="liip_doctrine_cache.memcached.class">Doctrine\Common\Cache\MemcachedCache</parameter>
<parameter key="liip_doctrine_cache.memcached_host">localhost</parameter>
<parameter key="liip_doctrine_cache.memcached_port">11211</parameter>
<parameter key="liip_doctrine_cache.redis.class">Doctrine\Common\Cache\RedisCache</parameter>
<parameter key="liip_doctrine_cache.redis_host">localhost</parameter>
<parameter key="liip_doctrine_cache.redis_port">6379</parameter>
<parameter key="liip_doctrine_cache.redis_timeout">2</parameter>
<parameter key="liip_doctrine_cache.php_file.class">Doctrine\Common\Cache\PhpFileCache</parameter>
<parameter key="liip_doctrine_cache.win_cache.class">Doctrine\Common\Cache\WinCacheCache</parameter>
<parameter key="liip_doctrine_cache.xcache.class">Doctrine\Common\Cache\XcacheCache</parameter>
Expand All @@ -30,6 +34,7 @@
<service id="liip_doctrine_cache.file_system" class="%liip_doctrine_cache.file_system.class%" abstract="true" />
<service id="liip_doctrine_cache.memcache" class="%liip_doctrine_cache.memcache.class%" abstract="true" />
<service id="liip_doctrine_cache.memcached" class="%liip_doctrine_cache.memcached.class%" abstract="true" />
<service id="liip_doctrine_cache.redis" class="%liip_doctrine_cache.redis.class%" abstract="true" />
<service id="liip_doctrine_cache.php_file" class="%liip_doctrine_cache.php_file.class%" abstract="true" />
<service id="liip_doctrine_cache.win_cache" class="%liip_doctrine_cache.win_cache.class%" abstract="true" />
<service id="liip_doctrine_cache.xcache" class="%liip_doctrine_cache.xcache.class%" abstract="true" />
Expand Down

0 comments on commit 4e90369

Please sign in to comment.