2017 © Pedro Peláez
 

symfony-bundle doctrine-cache-extension-bundle

Symfony2 Bundle extending doctrine cache capabilities

image

openclassrooms/doctrine-cache-extension-bundle

Symfony2 Bundle extending doctrine cache capabilities

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

The README.md

Build Status SensioLabsInsight Coverage Status, (*1)

The DoctrineCacheExtensionBundle offers integration of the DoctrineCacheExtension library. DoctrineCacheExtension provides functionality to handle cache management: * Default lifetime * Fetch with a namespace * Save with a namespace * Cache invalidation through namespace strategy * Data collector available in the profiler (not implemented yet), (*2)

See OpenClassrooms/DoctrineCacheExtension for more details., (*3)

Installation

This bundle can be installed using composer:, (*4)

composer require openclassrooms/doctrine-cache-extension-bundle or by adding the package directly to the composer.json file., (*5)

{
    "require": {
        "openclassrooms/doctrine-cache-extension-bundle": "*"
    }
}

After the package has been installed, add the bundle and the DoctrineCacheBundle to the AppKernel.php file:, (*6)

// in AppKernel::registerBundles()
$bundles = [
    // ...
    new new \Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle();
    new OpenClassrooms\Bundle\DoctrineCacheExtensionBundle\OpenClassroomsDoctrineCacheExtensionBundle(),
    // ...
)];

Configuration

# app/config/config.yml

doctrine_cache_extension:
    default_lifetime: 10 #optional, default = 0

To configure the cache providers, use the DoctrineCacheBundle configuration. For example:, (*7)

# app/config/config.yml

doctrine_cache:
    providers:
        a_cache_provider:
            type: array

Usage

$cache = $container->get('doctrine_cache.providers.a_cache_provider');

$cache->fetch($id);
$cache->fetchWithNamespace($id, $namespaceId);
$cache->save($id, $data);
$cache->saveWithNamespace($id, $data, $namespaceId);
$cache->invalidate($namespaceId);

Profiler

The bundle provides data in the profiler such as the number of calls, kinds of calls, and more. (picture), (*8)

The Versions