Skip to content
This repository has been archived by the owner on Nov 27, 2020. It is now read-only.

phpro/annotated-cache-bundle

Repository files navigation

Repository abandoned 2020-11-27

This repository has been archived since we are not using it anymore internally. Feel free to use it AS-IS, we won't be providing any support anymore.

Build status Insight Installs Packagist

Annotated Cache bundle

Installation

composer require phpro/annotated-cache-bundle
# AppKernel.php
public function registerBundles()
{
    $bundles = [
        // Bundles ....
        new Phpro\AnnotatedCacheBundle\AnnotatedCacheBundle(),
    ];

    return $bundles;
}

Note: If you want to use cached services with multiple tags, it's recommended to register this bundle as early as possible.

Configuration

# Default configuration for extension with alias: "annotated_cache"
annotated_cache:
    key_generator: phpro.annotated_cache.keygenerator.expressions
    proxy_config:
        cache_dir: '%kernel.cache_dir%/annotated_cache'
        namespace: AnnotatedCacheGeneratedProxy
        register_autoloader: true
    pools:
        # Example:
        poolname:
            service: service.key

Generate proxies

services:
    app.manager.products:
        class: App\Manager\ProductsManager
        tags:
            - { name: 'annotated_cache.eligable' }

You can register your own services to use a caching proxy instead. The only thing you will have to do is to tag your service with the annotated_cache.eligable tag.

Configure your own interceptor

services:
    app.interceptor.my_interceptor:
        class: App\Interceptor\MyInterceptor
        tags:
            - { name: 'annotated_cache.interceptor' }

Adding your own functionality is easy. Create your own InterceptorInterface and tag it with the annotated_cache.interceptor tag.