Skip to content

Commit e57c31b

Browse files
Merge pull request #46 from cleverage/45
#45 - Give a code to the custom cache task example
2 parents 069b883 + 7a7c4dc commit e57c31b

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

‎docs/index.md‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,10 @@ declare(strict_types=1);
6363
namespace App\Task;
6464
6565
use CleverAge\CacheProcessBundle\Task\AbstractCacheTask;
66+
use CleverAge\ProcessBundle\Attribute\AsTask;
6667
use CleverAge\ProcessBundle\Model\ProcessState;
6768
69+
#[AsTask(code: 'app_cache_delete')]
6870
class DeleteTask extends AbstractCacheTask
6971
{
7072
public function execute(ProcessState $state): void
@@ -77,15 +79,26 @@ class DeleteTask extends AbstractCacheTask
7779
}
7880
```
7981

82+
Its code is given by the `#[AsTask]` attribute (`cleverage/process-bundle` 5.4 or later), prefixed to avoid conflicts
83+
with the codes of the bundles. With autoconfiguration, the task is also non-shared and logs in the
84+
`cleverage_process_task` channel:
85+
8086
```yaml
8187
# config/services.yaml
8288
services:
8389
App\Task\DeleteTask:
84-
public: true
85-
shared: false
90+
autoconfigure: true
8691
arguments: ['@cleverage_cache_process.registry.adapter']
8792
```
8893

94+
```yaml
95+
delete_from_cache:
96+
task: app_cache_delete
97+
options:
98+
adapter: app
99+
key: my_key
100+
```
101+
89102
## Reference
90103

91104
- [Adapter](reference/adapter.md)

0 commit comments

Comments
 (0)