CleverAge/ProcessBundle must be installed.
Make sure Composer is installed globally, as explained in the installation chapter of the Composer documentation.
Open a command console, enter your project directory and install it using composer:
composer require cleverage/cache-process-bundleRemember to add the following line to config/bundles.php (not required if Symfony Flex is used)
CleverAge\CacheProcessBundle\CleverAgeCacheProcessBundle::class => ['all' => true],The bundle has no semantic configuration. To use the cache tasks, declare at least one cache
adapter: a service implementing CleverAge\CacheProcessBundle\Adapter\AdapterInterface
(usually CleverAge\CacheProcessBundle\Adapter\Adapter, wrapping any Symfony cache pool), tagged
cleverage.cache.adapter. Its code is then used in the adapter option of the tasks.
# config/services.yaml
services:
app.cleverage_cache_process.adapter.app:
class: CleverAge\CacheProcessBundle\Adapter\Adapter
arguments: ['@cache.app', 'app']
tags:
- { name: cleverage.cache.adapter }CleverAge\CacheProcessBundle\Task\AbstractCacheTask can be extended to implement other cache operations. It extends
AbstractConfigurableTask, requires
the cleverage_cache_process.registry.adapter service (AdapterRegistry) as constructor argument, defines the
adapter and key string options (required once merged with the input, see getRequiredOptions()), and provides
getMergedOptions() (options merged with the array input, resolved again so that the input values are validated, and
key validated) and $this->registry->getAdapter($code).
<?php
declare(strict_types=1);
namespace App\Task;
use CleverAge\CacheProcessBundle\Task\AbstractCacheTask;
use CleverAge\ProcessBundle\Model\ProcessState;
class DeleteTask extends AbstractCacheTask
{
public function execute(ProcessState $state): void
{
/** @var array{adapter: string, key: string} $options */
$options = $this->getMergedOptions($state);
$this->registry->getAdapter($options['adapter'])->deleteItem($options['key']);
}
}# config/services.yaml
services:
App\Task\DeleteTask:
public: true
shared: false
arguments: ['@cleverage_cache_process.registry.adapter']