Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for prefixed cache (#51)
* Add support for prefixed cache * Fixed issue with requiring service to be an object
- Loading branch information
Showing
2 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of php-cache organization. | ||
* | ||
* (c) 2015-2015 Aaron Scherer <aequasi@gmail.com>, Tobias Nyholm <tobias.nyholm@gmail.com> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace Cache\AdapterBundle\Factory; | ||
|
||
use Cache\Prefixed\PrefixedCachePool; | ||
use Symfony\Component\OptionsResolver\OptionsResolver; | ||
|
||
class PrefixedFactory extends AbstractAdapterFactory | ||
{ | ||
protected static $dependencies = [ | ||
['requiredClass' => 'Cache\Prefixed\PrefixedCachePool', 'packageName' => 'cache/prefixed-cache'], | ||
]; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getAdapter(array $config) | ||
{ | ||
return new PrefixedCachePool($config['service'], $config['prefix']); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected static function configureOptionResolver(OptionsResolver $resolver) | ||
{ | ||
parent::configureOptionResolver($resolver); | ||
|
||
$resolver->setRequired(['prefix', 'service']); | ||
$resolver->setAllowedTypes('prefix', ['string']); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters