openclassrooms / doctrine-cache-extension-bundle
Symfony2 Bundle extending doctrine cache capabilities
Installs: 84 112
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 25
Forks: 1
Open Issues: 1
Type:symfony-bundle
Requires
- php: >=7.1
- doctrine/doctrine-cache-bundle: ~1.3
- openclassrooms/doctrine-cache-extension: 1.0.*@dev
- symfony/config: ~3.4 || ~4.0
- symfony/dependency-injection: ~3.4 || ~4.0
- symfony/http-kernel: ~3.4 || ~4.0
- symfony/stopwatch: ~3.4 || ~4.0
Requires (Dev)
This package is auto-updated.
Last update: 2025-01-15 16:42:49 UTC
README
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)
See OpenClassrooms/DoctrineCacheExtension for more details.
Installation
This bundle can be installed using composer:
composer require openclassrooms/doctrine-cache-extension-bundle
or by adding the package directly to the composer.json file.
{ "require": { "openclassrooms/doctrine-cache-extension-bundle": "*" } }
After the package has been installed, add the bundle and the DoctrineCacheBundle to the AppKernel.php file:
// 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:
# 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)