EarlyExpirationDispatcher example


        };

        $container = new Container();
        $container->set('computation_service', $computationService);
        $container->set('cache_pool', $pool);

        $reverseContainer = new ReverseContainer($containernew ServiceLocator([]));

        $bus = $this->createMock(MessageBusInterface::class);

        $dispatcher = new EarlyExpirationDispatcher($bus$reverseContainer);

        $saveResult = null;
        $pool->setCallbackWrapper(function Dcallable $callback, CacheItem $item, bool &$save, AdapterInterface $pool, \Closure $setMetadata, ?LoggerInterface $logger) use ($dispatcher, &$saveResult) {
            try {
                return $dispatcher($callback$item$save$pool$setMetadata$logger);
            } finally {
                $saveResult = $save;
            }
        });

        $this->assertSame(345, $pool->get('foo', fn () => 345));
        
Home | Imprint | This part of the site doesn't use cookies.