Skip to content

Commit 1e5f5f8

Browse files
[Cache] add integration with Messenger to allow computing cached values in a worker
1 parent b281490 commit 1e5f5f8

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

DependencyInjection/Configuration.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,9 @@ private function addCacheSection(ArrayNodeDefinition $rootNode)
10411041
->scalarNode('provider')
10421042
->info('Overwrite the setting from the default provider for this adapter.')
10431043
->end()
1044+
->scalarNode('early_expiration_message_bus')
1045+
->example('"messenger.default_bus" to send early expiration events to the default Messenger bus.')
1046+
->end()
10441047
->scalarNode('clearer')->end()
10451048
->end()
10461049
->end()

DependencyInjection/FrameworkExtension.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@
147147
use Symfony\Component\Yaml\Command\LintCommand as BaseYamlLintCommand;
148148
use Symfony\Component\Yaml\Yaml;
149149
use Symfony\Contracts\Cache\CacheInterface;
150+
use Symfony\Contracts\Cache\CallbackInterface;
150151
use Symfony\Contracts\Cache\TagAwareCacheInterface;
151152
use Symfony\Contracts\HttpClient\HttpClientInterface;
152153
use Symfony\Contracts\Service\ResetInterface;
@@ -436,6 +437,8 @@ public function load(array $configs, ContainerBuilder $container)
436437
->addTag('container.env_var_loader');
437438
$container->registerForAutoconfiguration(EnvVarProcessorInterface::class)
438439
->addTag('container.env_var_processor');
440+
$container->registerForAutoconfiguration(CallbackInterface::class)
441+
->addTag('container.reversible');
439442
$container->registerForAutoconfiguration(ServiceLocator::class)
440443
->addTag('container.service_locator');
441444
$container->registerForAutoconfiguration(ServiceSubscriberInterface::class)

Resources/config/cache.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter;
2626
use Symfony\Component\Cache\Adapter\TagAwareAdapter;
2727
use Symfony\Component\Cache\Marshaller\DefaultMarshaller;
28+
use Symfony\Component\Cache\Messenger\EarlyExpirationHandler;
2829
use Symfony\Component\HttpKernel\CacheClearer\Psr6CacheClearer;
2930
use Symfony\Contracts\Cache\CacheInterface;
3031
use Symfony\Contracts\Cache\TagAwareCacheInterface;
@@ -212,6 +213,12 @@
212213
null, // use igbinary_serialize() when available
213214
])
214215

216+
->set('cache.early_expiration_handler', EarlyExpirationHandler::class)
217+
->args([
218+
service('reverse_container'),
219+
])
220+
->tag('messenger.message_handler')
221+
215222
->set('cache.default_clearer', Psr6CacheClearer::class)
216223
->args([
217224
[],

Resources/config/schema/symfony-1.0.xsd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@
284284
<xsd:attribute name="public" type="xsd:boolean" />
285285
<xsd:attribute name="default-lifetime" type="xsd:integer" />
286286
<xsd:attribute name="provider" type="xsd:string" />
287+
<xsd:attribute name="early-expiration-message-bus" type="xsd:string" />
287288
<xsd:attribute name="clearer" type="xsd:string" />
288289
</xsd:complexType>
289290

0 commit comments

Comments
 (0)