Open
Description
Hey! Seems like an example of a callback in async cache section is incorrect:
$cachedValue = $asyncCache->get('my_value', [CacheComputation::class, 'compute'])
It's not a valid callback as the compute
method is not static in the example:
class CacheComputation
{
public function compute(ItemInterface $item): string
{
...
}
}
Am I missing something or we should adjust the docs?
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
torchello commentedon Apr 10, 2025
Actually, some info from this page could be added to the docs. Wdyt?
https://symfony.com/blog/new-in-symfony-5-2-async-cache-recomputing
torchello commentedon Apr 11, 2025
Also, seems like
should be
nicolas-grekas commentedon May 23, 2025
About the callback: the callable can be a pseudo-callable, where the "object" on which the method is called is actually its service name. So the doc should work. There's something called
EarlyExpirationDispatcher
which will turn the string into the corresponding service.About
messenger.default_bus
vsmessenger.bus.default
, both should work.Did you give all this a try?
PR welcome of course!
torchello commentedon Jun 25, 2025
I could only make it working with:
and
I will double check again and will post the error messages I'm getting.