Merge pull request #10 from aderuwe/apc-adapter

Implement APC adapter
This commit is contained in:
Antoine Hérault 2011-12-18 11:59:13 -08:00
commit e1c3063275
4 changed files with 78 additions and 0 deletions

View File

@ -0,0 +1,48 @@
<?php
namespace Knp\Bundle\GaufretteBundle\DependencyInjection\Factory;
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\DefinitionDecorator;
/**
* Apc adapter factory
*
* @author Alexander Deruwe <alexander.deruwe@gmail.com>
*/
class ApcAdapterFactory implements AdapterFactoryInterface
{
/**
* {@inheritDoc}
*/
public function create(ContainerBuilder $container, $id, array $config)
{
$container
->setDefinition($id, new DefinitionDecorator('knp_gaufrette.adapter.apc'))
->replaceArgument(0, $config['prefix'])
->replaceArgument(1, $config['ttl'])
;
}
/**
* {@inheritDoc}
*/
public function getKey()
{
return 'apc';
}
/**
* {@inheritDoc}
*/
public function addConfiguration(NodeDefinition $node)
{
$node
->children()
->scalarNode('prefix')->isRequired()->cannotBeEmpty()->end()
->scalarNode('ttl')->defaultValue(0)->end()
->end()
;
}
}

View File

@ -315,3 +315,26 @@ knp_gaufrette:
create: true
mode: FTP_BINARY
```
## Apc
Adapter for APC.
A non-persistent adapter, use it in the dev environment, in demo sites, ...
### Parameters
* `prefix` The prefix to this filesystem (APC 'namespace', it is recommended that this end in a dot '.') *(required)*
* `ttl` Time to live *(default 0)*
### Example
``` yaml
# app/config/config.yml
knp_gaufrette:
adapters:
foo:
apc:
prefix: APC 'namespace' prefix
ttl: 0
```

View File

@ -32,6 +32,9 @@
<service id="knp_gaufrette.adapter.factory.ftp" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\FtpAdapterFactory">
<tag name="gaufrette.adapter.factory" />
</service>
<service id="knp_gaufrette.adapter.factory.apc" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\ApcAdapterFactory">
<tag name="gaufrette.adapter.factory" />
</service>
</services>

View File

@ -27,6 +27,10 @@
<argument /><!-- hosts -->
</service>
<service id="knp_gaufrette.adapter.ftp" class="Gaufrette\Adapter\Ftp" abstract="true" public="false" />
<service id="knp_gaufrette.adapter.apc" class="Gaufrette\Adapter\Apc" abstract="true" public="false">
<argument /><!-- prefix -->
<argument /><!-- ttl -->
</service>
<service id="knp_gaufrette.filesystem_map" class="Knp\Bundle\GaufretteBundle\FilesystemMap">
<argument /> <!-- map of filesystems -->
</service>