Skip to content

Commit

Permalink
Add Varnish cache clear command.
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Nikolaev committed Sep 10, 2020
1 parent 15b7865 commit f783aeb
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,5 @@ $ /usr/bin/env php bin/console darvin:utils:translations:title-case <pathname>
7.3.8: Add HTTP cache clear command.

7.3.9: Remove integration with yandex translate API.

7.3.10: Add Varnish cache clear command.
7 changes: 7 additions & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ public function getConfigTreeBuilder(): TreeBuilder
->scalarNode('dir')->defaultValue('%kernel.cache_dir%/http_cache')->cannotBeEmpty()->end()
->end()
->end()
->arrayNode('varnish')->canBeEnabled()
->children()
->scalarNode('url')->isRequired()->cannotBeEmpty()->end()
->scalarNode('method')->defaultValue('XCGFULLBAN')->cannotBeEmpty()->end()
->integerNode('timeout')->defaultValue(3)->min(1)->end()
->end()
->end()
->end()
->end()
->arrayNode('response')->addDefaultsIfNotSet()
Expand Down
4 changes: 4 additions & 0 deletions DependencyInjection/DarvinUtilsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ public function load(array $configs, ContainerBuilder $container): void
return $config['cache']['http']['enabled'];
}],

'cache/varnish' => ['extension' => 'curl', 'callback' => function () use ($config): bool {
return $config['cache']['varnish']['enabled'];
}],

'cloner/common' => ['class' => self::CLASS_PROPERTY_ACCESS],
'cloner/uploadable' => ['class' => [self::CLASS_PROPERTY_ACCESS, self::CLASS_FILESYSTEM], 'bundle' => self::BUNDLE_UPLOADER],

Expand Down
21 changes: 21 additions & 0 deletions Resources/config/services/cache/varnish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
parameters:
darvin_utils.cache.varnish.clear.clearer.class: Darvin\Utils\Cache\Varnish\VarnishCacheClearer

darvin_utils.cache.varnish.clear.command.class: Darvin\Utils\Command\Cache\Varnish\ClearCommand
darvin_utils.cache.varnish.clear.command.name: darvin:utils:varnish-cache:clear

services:
darvin_utils.cache.varnish.clear.clearer:
class: '%darvin_utils.cache.varnish.clear.clearer.class%'
arguments:
- '%darvin_utils.cache.varnish.url%'
- '%darvin_utils.cache.varnish.method%'
- '%darvin_utils.cache.varnish.timeout%'

darvin_utils.cache.varnish.clear.command:
class: '%darvin_utils.cache.varnish.clear.command.class%'
arguments:
- '%darvin_utils.cache.varnish.clear.command.name%'
- '@darvin_utils.cache.varnish.clear.clearer'
tags:
- { name: console.command }

0 comments on commit f783aeb

Please sign in to comment.