final class ProtectiveFoilOfferCollectionCacheLoaderDecorator implements ProtectiveFoilOfferCollectionLoaderInterface
{
private CacheProviderInterface $cacheProvider;
private ProtectiveFoilOfferCollectionLoaderInterface $protectiveFoilOfferCollectionLoader;
public function __construct(
ProtectiveFoilOfferCollectionLoaderInterface $protectiveFoilOfferCollectionLoader,
CacheProviderInterface $cacheProvider
) {
$this->protectiveFoilOfferCollectionLoader = $protectiveFoilOfferCollectionLoader;
$this->cacheProvider = $cacheProvider;
}
public function loadByFoilIndexesAndWebsite(
array $foilIndexes,
int $websiteId
): ProtectiveFoilOfferDTOCollection {
return $this->cacheProvider->load(
sprintf('protecitve_foil_offer_collection_and_website_%s_%d', implode('_', $foilIndexes), $websiteId),
CacheLifetime::THREE_MINUTES,
function () use ($foilIndexes, $websiteId): ProtectiveFoilOfferDTOCollection {
return $this->protectiveFoilOfferCollectionLoader->loadByFoilIndexesAndWebsite(
$foilIndexes,
$websiteId
);
}
);
}
public function __call(string $name, array $arguments)
{
return call_user_func_array([$this->protectiveFoilOfferCollectionLoader, $name], $arguments);
}
}