2017 © Pedro Peláez
 

library doctrine-cache-extension

Library extending doctrine cache capabilities

image

openclassrooms/doctrine-cache-extension

Library extending doctrine cache capabilities

  • Tuesday, December 6, 2016
  • by openclassrooms-admin
  • Repository
  • 5 Watchers
  • 0 Stars
  • 14,327 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 14 % Grown

The README.md

Doctrine Cache Extension

Build Status SensioLabsInsight Coverage Status, (*1)

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)

Installation

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');

Default lifetime

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);

Fetch with namespace

$data = $cacheProviderDecorator->fetchWithNamespace($id, $namespaceId);

Save with namespace

// Namespace and life time can be null
$data = $cacheProviderDecorator->saveWithNamespace($id, $data, $namespaceId, $lifeTime);

Cache invalidation

$cacheProviderDecorator->invalidate($namespaceId);

The Versions

06/12 2016

dev-master

9999999-dev

Library extending doctrine cache capabilities

  Sources   Download

MIT

The Requires

 

The Development Requires

by OpenClassrooms
by Romain Kuzniak