Skip to content

Commit a09f7b6

Browse files
committed
minor #19678 Fixes async cache computation example and FQCN (mvhirsch)
This PR was merged into the 5.4 branch. Discussion ---------- Fixes async cache computation example and FQCN Fixes invalid documentation. Took me an hour to figure it out. Thankfully, every new feature gets a blog post (thx `@nicolas`-grekas): https://symfony.com/blog/new-in-symfony-5-2-async-cache-recomputing I'll provide another MR with a working example using a DI service (needs `CallbackInterface` or service must be public). Commits ------- 12559a1 fixes async cache computation example and FQCN
2 parents a43d1a7 + 12559a1 commit a09f7b6

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

cache.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ In the following example, the value is requested from a controller::
907907
public function index(CacheInterface $asyncCache): Response
908908
{
909909
// pass to the cache the service method that refreshes the item
910-
$cachedValue = $cache->get('my_value', [CacheComputation::class, 'compute'])
910+
$cachedValue = $asyncCache->get('my_value', [CacheComputation::class, 'compute'])
911911

912912
// ...
913913
}
@@ -925,13 +925,13 @@ a message bus to compute values in a worker:
925925
cache:
926926
pools:
927927
async.cache:
928-
early_expiration_message_bus: async_bus
928+
early_expiration_message_bus: messenger.default_bus
929929
930930
messenger:
931931
transports:
932932
async_bus: '%env(MESSENGER_TRANSPORT_DSN)%'
933933
routing:
934-
Symfony\Component\Cache\Messenger\Message\EarlyExpirationMessage: async_bus
934+
'Symfony\Component\Cache\Messenger\EarlyExpirationMessage': async_bus
935935
936936
.. code-block:: xml
937937
@@ -947,12 +947,12 @@ a message bus to compute values in a worker:
947947
>
948948
<framework:config>
949949
<framework:cache>
950-
<framework:pool name="async.cache" early-expiration-message-bus="async_bus"/>
950+
<framework:pool name="async.cache" early-expiration-message-bus="messenger.default_bus"/>
951951
</framework:cache>
952952
953953
<framework:messenger>
954954
<framework:transport name="async_bus">%env(MESSENGER_TRANSPORT_DSN)%</framework:transport>
955-
<framework:routing message-class="Symfony\Component\Cache\Messenger\Message\EarlyExpirationMessage">
955+
<framework:routing message-class="Symfony\Component\Cache\Messenger\EarlyExpirationMessage">
956956
<framework:sender service="async_bus"/>
957957
</framework:routing>
958958
</framework:messenger>
@@ -969,7 +969,7 @@ a message bus to compute values in a worker:
969969
return static function (FrameworkConfig $framework): void {
970970
$framework->cache()
971971
->pool('async.cache')
972-
->earlyExpirationMessageBus('async_bus');
972+
->earlyExpirationMessageBus('messenger.default_bus');
973973
974974
$framework->messenger()
975975
->transport('async_bus')

0 commit comments

Comments
 (0)