public function afterMethodExecution(MethodInvocation $invocation)
    {
        $filesystemAdapter = new Local(APP_BASE_DIR . 'storage/cache/api/');
        $filesystem        = new Filesystem($filesystemAdapter);

        $pool = new FilesystemCachePool($filesystem);

        $cacheKey = "products_" . md5(implode('_', $invocation->getArguments()));

        $item = $pool->getItem($cacheKey);
        $normalizer = new ObjectNormalizer();

        if ($item->isHit()) { // found the item in cache
            /** @var MapProduct $cacheItem */
            $cacheItem = $normalizer->denormalize($item->get(), MapProduct::class);
            return $cacheItem;
        }

        // execute the API call
        /** @var \KickAss\Commerce\Product\Map\Product $returnValue */
        $returnValue = $invocation->proceed();

        $item->set($normalizer->normalize($returnValue, 'array'))
            ->setTags(['products']);
        $item->expiresAfter(3600);

        $pool->save($item);

        // return value as expected
        return $returnValue;
    }
public function afterMethodExecution(MethodInvocation $invocation)
    {
        $filesystemAdapter = new Local(APP_BASE_DIR . 'storage/cache/api/');
        $filesystem        = new Filesystem($filesystemAdapter);

        $pool = new FilesystemCachePool($filesystem);

        $cacheKey = "products_" . md5(implode('_', $invocation->getArguments()));

        $item = $pool->getItem($cacheKey);
        $normalizer = new ObjectNormalizer();

        if ($item->isHit()) { // found the item in cache
            /** @var MapProduct $cacheItem */
            $cacheItem = $normalizer->denormalize($item->get(), MapProduct::class);
            return $cacheItem;
        }

        // execute the API call
        /** @var \KickAss\Commerce\Product\Map\Product $returnValue */
        $returnValue = $invocation->proceed();

        $item->set($normalizer->normalize($returnValue, 'array'))
            ->setTags(['products']);
        $item->expiresAfter(3600);

        $pool->save($item);

        // return value as expected
        return $returnValue;
    }
public function afterMethodExecution ( MethodInvocation $ invocation ) { $ filesystemAdapter = new Local ( APP_BASE_DIR . 'storage/cache/api/' ) ; $ filesystem = new Filesystem ( $ filesystemAdapter ) ; $ pool = new FilesystemCachePool ( $ filesystem ) ; $ cacheKey = "products_" . md5 ( implode ( '_' , $ invocation -> getArguments ( ) ) ) ; $ item = $ pool -> getItem ( $ cacheKey ) ; $ normalizer = new ObjectNormalizer ( ) ; if ( $ item -> isHit ( ) ) { // found the item in cache /** @var MapProduct $cacheItem */ $ cacheItem = $ normalizer -> denormalize ( $ item -> get ( ) , MapProduct :: class ) ; return $ cacheItem ; } // execute the API call /** @var \KickAss\Commerce\Product\Map\Product $returnValue */ $ returnValue = $ invocation -> proceed ( ) ; $ item -> set ( $ normalizer -> normalize ( $ returnValue , 'array' ) ) -> setTags ( [ 'products' ] ) ; $ item -> expiresAfter ( 3600 ) ; $ pool -> save ( $ item ) ; // return value as expected return $ returnValue ; }
Cache bridge file response

@param MethodInvocation $invocation
@return \KickAss\Commerce\Product\Map\Product

@Around("execution(public KickAss\Commerce\Product\Repository\Product->loadByAttribute(*))")
Cache bridge file response