mmoreram/cache-flush-bundle

Symfony cache flusher

Installs: 18 505

Dependents: 2

Suggesters: 0

Security: 0

Stars: 1

Watchers: 3

Forks: 0

Open Issues: 0

Type:symfony-bundle

v1.0.1 2016-12-28 09:59 UTC

This package is auto-updated.

Last update: 2024-11-29 04:46:55 UTC


README

Build Status

Flush all your kernel content with a simple Symfony service.

$this
    ->container
    ->get('cache_flusher')
    ->flushCache()

by default the service will flush the cache of the kernel loaded in the framework, but you can explicitly flush one kernel's cache by passing the kernel as the first and unique method's parameter.

$myOtherKernel = //
$this
    ->container
    ->get('cache_flusher')
    ->flushCache($myOtherKernel)

You can inject the service as well.

my_service:
    class: MyService\Namespace
    arguments:
        '@cache_flusher'

The service dispatches as well two events, one just before flush the kernel's cache, and another one just after. In both cases, an instance of CacheFlushEvent is dispatched, with the used kernel inside.

my_event_listener:
    class: MyEventListener\Namespace
    tags:
        - { name: kernel.event_listener, event: cache.pre_flush }
        - { name: kernel.event_listener, event: cache.on_flush }