Пример #1
0
 /**
  * Clear cache action
  */
 public function clearCacheAction()
 {
     $cache = $this->Request()->getPost('cache', array());
     $cacheInstance = $this->cacheManager->getCoreCache();
     $capabilities = $cacheInstance->getBackend()->getCapabilities();
     if (empty($capabilities['tags'])) {
         if ($cache['config'] == 'on' || $cache['template'] == 'on') {
             $cacheInstance->clean();
         }
     } else {
         $tags = array();
         if ($cache['config'] == 'on' || $cache['backend'] == 'on') {
             $tags[] = 'Shopware_Config';
             $tags[] = 'Shopware_Plugin';
         }
         if ($cache['search'] == 'on') {
             $tags[] = 'Shopware_Modules_Search';
         }
         if ($cache['backend'] == 'on') {
             $tags[] = 'Shopware_Config';
         }
         if ($cache['proxy'] == 'on') {
             $tags[] = 'Shopware_Models';
         }
         if (!empty($tags) && $tags < 7) {
             $cacheInstance->clean(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, $tags);
         } else {
             $cacheInstance->clean();
         }
     }
     if ($cache['config'] == 'on' || $cache['backend'] == 'on' || $cache['frontend'] == 'on') {
         $this->cacheManager->clearTemplateCache();
     }
     if ($cache['search'] == 'on') {
         $this->cacheManager->clearSearchCache();
     }
     if ($cache['router'] == 'on') {
         $this->cacheManager->clearRewriteCache();
     }
     if ($cache['template'] == 'on' || $cache['backend'] == 'on' || $cache['frontend'] == 'on') {
         $this->cacheManager->clearTemplateCache();
     }
     if ($cache['theme'] == 'on' || $cache['frontend'] == 'on') {
         $this->cacheManager->clearHttpCache();
     }
     if ($cache['http'] == 'on' || $cache['frontend'] == 'on') {
         $this->cacheManager->clearHttpCache();
     }
     if ($cache['proxy'] == 'on') {
         $this->cacheManager->clearProxyCache();
     }
     $this->View()->assign(array('success' => true));
 }
Пример #2
0
 /**
  * Clears a given cache info item. This method maintains compatibility with the odl cache module's behaviour.
  *
  * @param string $cache
  * @throws \Shopware\Components\Api\Exception\NotFoundException
  */
 protected function clearCache($cache)
 {
     $capabilities = $this->cacheManager->getCoreCache()->getBackend()->getCapabilities();
     if ($cache == 'all') {
         $this->cacheManager->getCoreCache()->clean();
         $this->cacheManager->clearHttpCache();
         $this->cacheManager->clearConfigCache();
         $this->cacheManager->clearTemplateCache();
         $this->cacheManager->clearProxyCache();
         $this->cacheManager->clearSearchCache();
         return;
     }
     switch ($cache) {
         case 'http':
             $this->cacheManager->clearHttpCache();
             break;
         case 'config':
             $tags[] = 'Shopware_Config';
             $tags[] = 'Shopware_Plugin';
             $this->cacheManager->clearConfigCache();
             break;
         case 'template':
             $this->cacheManager->clearTemplateCache();
             break;
         case 'backend':
             $tags[] = 'Shopware_Config';
             $tags[] = 'Shopware_Plugin';
             $this->cacheManager->clearTemplateCache();
             break;
         case 'proxy':
             $tags[] = 'Shopware_Models';
             $this->cacheManager->clearProxyCache();
             break;
         case 'doctrine-proxy':
             $tags[] = 'Shopware_Models';
             $this->cacheManager->clearProxyCache();
             break;
         case 'doctrine-file':
             $tags[] = 'Shopware_Models';
             $this->cacheManager->clearProxyCache();
             break;
         case 'search':
             $tags[] = 'Shopware_Modules_Search';
             $this->cacheManager->clearSearchCache();
             break;
         case 'rewrite':
             $this->cacheManager->clearRewriteCache();
             break;
         default:
             throw new ApiException\NotFoundException("Cache {$cache} is not a valid cache id.");
     }
     if (!empty($capabilities['tags'])) {
         if (!empty($tags)) {
             $this->cacheManager->getCoreCache()->clean(\Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, $tags);
         } else {
             $this->cacheManager->getCoreCache()->clean();
         }
     }
 }
 /**
  * @param string $token
  * @param int $expiresIn
  */
 private function setAuthorizationToCache($token, $expiresIn)
 {
     //Decrease expire date by one hour (3600s) just to make sure, we don't run into an unauthorized exception.
     $this->cacheManager->getCoreCache()->save($token, self::CACHE_ID, array(), $expiresIn - 3600);
 }