dev-master
9999999-devLibrary extending doctrine cache capabilities
MIT
The Requires
- php >=5.6
- doctrine/cache ~1.0
The Development Requires
by OpenClassrooms
by Romain Kuzniak
Wallogit.com
2017 © Pedro Peláez
Library extending doctrine cache capabilities
The Doctrine Cache extension adds the following features to Doctrine Cache implementation: - Default lifetime - Fetch with a namespace - Save with a namespace - Cache invalidation through namespace strategy, (*2)
The easiest way to install DoctrineCacheExtension is via composer., (*3)
Create the following composer.json file and run the php composer.phar install command to install it., (*4)
{
"require": {
"openclassrooms/doctrine-cache-extension": "*"
}
}
```php <?php require 'vendor/autoload.php';, (*5)
use OpenClassrooms\DoctrineCacheExtension\CacheProviderDecorator;, (*6)
//do things, (*7)
<a name="install-nocomposer"/> ## Usage ### Instantiation OpenClassrooms CacheProviderDecorator needs a Doctrine CacheProvider to be instantiated. ```php $cacheProvider = new ArrayCache(); $cacheProviderDecorator = new CacheProviderDecorator($cacheProvider);
A factory can be used to accomplish this., (*8)
$factory = new CacheProviderDecoratorFactory();
$cacheProvider = $factory->create('array');
Specify lifetime in the constructor:, (*9)
$cacheProviderDecorator = new CacheProviderDecorator($cacheProvider, 100); $cacheProviderDecorator->save($id, $data);
Or via the factory:, (*10)
$cacheProvider = $factory->create('array', 100);
Or specify a default lifetime for all the cache providers:, (*11)
$factory = new CacheProviderDecoratorFactory(); $factory->setDefaultLifetime(100);
$data = $cacheProviderDecorator->fetchWithNamespace($id, $namespaceId);
// Namespace and life time can be null $data = $cacheProviderDecorator->saveWithNamespace($id, $data, $namespaceId, $lifeTime);
$cacheProviderDecorator->invalidate($namespaceId);
Library extending doctrine cache capabilities
MIT