protected function clearTaxonomyTerms(Collection $collection) { foreach ($collection as $term) { if ($term instanceof TaxonomyTermInterface) { $this->cacheService->clearByTags(['route_taxonomy/term/get', 'param_term_' . $term->getId()]); } } }
protected function clearParents(TaxonomyTermInterface $term) { if ($term->hasParent()) { $parent = $term->getParent(); $this->cacheService->clearByTags(['route_taxonomy/term/get', 'param_term_' . $parent->getId()]); $this->clearParents($parent); } }
/** * @param CacheService $cacheService * @param ModuleOptions $options * @param ServiceLocatorInterface $serviceLocator */ protected function attachStrategiesToEventManager(CacheService $cacheService, ModuleOptions $options, ServiceLocatorInterface $serviceLocator) { // Register enabled strategies on the cacheListener $strategies = $options->getStrategies(); if (isset($strategies['enabled'])) { /** @var $strategyPluginManager \StrokerCache\Strategy\CacheStrategyPluginManager */ $strategyPluginManager = $serviceLocator->get('StrokerCache\\Strategy\\CacheStrategyPluginManager'); foreach ($strategies['enabled'] as $alias => $options) { if (is_numeric($alias)) { $alias = $options; } $strategy = $strategyPluginManager->get($alias, $options); if ($strategy instanceof ListenerAggregateInterface) { $listener = $strategy; } else { $listener = new ShouldCacheStrategyListener($strategy); } $cacheService->getEventManager()->attach($listener); } } }
public function testSettersProvideFluentInterface() { $service = $this->cacheService->setEventManager(new EventManager())->setCacheStorage($this->storageMock)->setOptions(new ModuleOptions()); $this->assertEquals($this->cacheService, $service); }