/**
  * Should handle execution of the task, taking as much (optional) parameters as needed
  *
  * The parameters should be optional and failing to provide them should be handled by
  * the task
  */
 public function execute($text = null)
 {
     if ($this->cache instanceof \Zend_Cache_Core) {
         $this->cache->clean(\Zend_Cache::CLEANING_MODE_ALL);
         $this->getBatch()->addMessage($this->_('Cache cleaned'));
     }
 }
Example #2
0
 public function testClean()
 {
     $this->rediska->set('test', array('aaa', time(), null));
     $reply = $this->cache->clean();
     $this->assertTrue($reply);
     $reply = $this->rediska->get('test');
     $this->assertNull($reply);
 }
Example #3
0
 /**
  * {@inheritdoc}
  *
  * @throws \InvalidArgumentException Exception is thrown when non-supported cleaning mode is specified
  */
 public function clean($mode = \Zend_Cache::CLEANING_MODE_ALL, array $tags = [])
 {
     // Cleaning modes 'old' and 'notMatchingTag' are prohibited as a trade off for decoration reliability
     if (!in_array($mode, [\Zend_Cache::CLEANING_MODE_ALL, \Zend_Cache::CLEANING_MODE_MATCHING_TAG, \Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG])) {
         throw new \InvalidArgumentException("Magento cache frontend does not support the cleaning mode '{$mode}'.");
     }
     return $this->_frontend->clean($mode, $this->_unifyIds($tags));
 }
Example #4
0
 /**
  * Remove cache matching id, prefix or tags
  * @param string $cacheId cache id to remove
  * @param string $cachePrefix cache prefix to remove
  * @param array $tags array of cache tags to remove
  */
 public function clean($cacheId = '', $cachePrefix = '', $tags = array())
 {
     $tags = $this->_sanitizeTags($tags);
     $this->_cache->clean(Zend_Cache::CLEANING_MODE_OLD);
     if (!$cachePrefix && !$cacheId) {
         if (is_array($tags) && !empty($tags)) {
             $this->_cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, $tags);
         } else {
             $this->_cache->clean(Zend_Cache::CLEANING_MODE_ALL);
         }
     } else {
         $cacheId = $this->_makeCacheId($cacheId, $cachePrefix);
         $this->_cache->remove($cacheId);
     }
 }
 /**
  * Overrule this function for any activities you want to take place
  * after the form has successfully been validated, but before any
  * buttons are processed.
  *
  * @param int $step The current step
  */
 protected function afterFormValidationFor($step)
 {
     if (3 == $step) {
         $import = $this->loadImportData();
         $model = $this->getModel();
         $saves = array();
         foreach ($model->getCol('exportCode') as $name => $exportCode) {
             if (isset($this->formData[$name]) && $this->formData[$name]) {
                 $saves[] = array('gsu_id_survey' => $this->formData[$name], 'gsu_export_code' => $exportCode);
                 $import['surveyCodes'][$exportCode] = $this->formData[$name];
             }
         }
         if ($saves) {
             $sModel = new \MUtil_Model_TableModel('gems__surveys');
             \Gems_Model::setChangeFieldsByPrefix($sModel, 'gus', $this->currentUser->getUserId());
             $sModel->saveAll($saves);
             $count = $sModel->getChanged();
             if ($count == 0) {
                 $this->addMessage($this->_('No export code changed'));
             } else {
                 $this->cache->clean(\Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, array('surveys'));
                 $this->addMessage(sprintf($this->plural('%d export code changed', '%d export codes changed', $count), $count));
             }
         }
     }
 }
 /**
  * @return controlar
  */
 private function _prepareAcl()
 {
     if (!is_null($this->usuario) && !is_null($this->usuario->ID_UNIDADE)) {
         // atualizar informações da unidade do usuário na sessão
         // com as informações do banco, a menos que o usuário tenha trocado
         // Testar a existência de um cache de acl para o usuário
         if (!$this->cache->test('acl_' . $this->usuario->ID)) {
             $this->acl = AclFactory::createAcl($this->usuario);
             $this->cache->save($this->acl, 'acl_' . $this->usuario->ID, array('acl_usuario_' . $this->usuario->ID, 'acl_unidade_' . $this->usuario->ID_UNIDADE));
         } else {
             $this->acl = $this->cache->load('acl_' . $this->usuario->ID);
             if ($this->usuario->ID_UNIDADE != $this->acl->getIdUnidade()) {
                 if (!$this->acl->isTrocouUnidade() && !$this->usuario->TROCOU) {
                     // id do cache e da session não batem, e usuário não trocou de unidade
                     // limpar o cache e recriá-lo
                     $this->cache->remove('acl_' . $this->usuario->ID);
                     $this->cache->clean('matchingAnyTag', array('acl_usuario_' . $this->usuario->ID));
                     $this->acl = AclFactory::createAcl($this->usuario);
                     $this->cache->save($this->acl, 'acl_' . $this->usuario->ID, array('acl_usuario_' . $this->usuario->ID, 'acl_unidade_' . $this->usuario->ID_UNIDADE));
                     // limpar
                 }
             }
             $this->usuario = $this->acl->updateSession();
         }
         // Forçar permissão de troca de unidades pro usuário que já trocou de unidade
         if ($this->acl->isTrocouUnidade()) {
             $this->acl->allow($this->usuario->ID, 115);
         }
     }
     return $this;
 }
Example #7
0
 /**
  * 重置缓存对象
  * 
  * @static
  * @return boolean 
  */
 public static function resetCache()
 {
     if (null !== self::$_cache) {
         return self::$_cache->clean();
     }
     return false;
 }
Example #8
0
 /**
  * Clean cached data by specific tag
  *
  * @return bool
  */
 public function flush()
 {
     Magento_Profiler::start('cache_flush', $this->_generateProfilerTags('flush'));
     $res = $this->_frontend->clean();
     Magento_Profiler::stop('cache_flush');
     return $res;
 }
Example #9
0
 /**
  * @group tags
  */
 public function testCleanAnyMatchingTag()
 {
     $this->setKeys();
     $this->cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, array('tag_a1', 'tag_a3'));
     $ids = $this->cache->getIds();
     sort($ids);
     $this->assertEquals(array('test_ccc'), $ids);
 }
Example #10
0
 /**
  * Clears all set cache data
  *
  * @return void
  */
 public static function clearCache()
 {
     if (self::$_cacheTags) {
         self::$_cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array('Zend_Locale'));
     } else {
         self::$_cache->clean(Zend_Cache::CLEANING_MODE_ALL);
     }
 }
Example #11
0
 /**
  * Hook that allows actions when data was saved
  *
  * When not rerouted, the form will be populated afterwards
  *
  * @param int $changed The number of changed rows (0 or 1 usually, but can be more)
  */
 protected function afterSave($changed)
 {
     if ($changed) {
         // Clean cache on changes
         if ($this->cacheTags && $this->cache instanceof \Zend_Cache_Core) {
             $this->cache->clean(\Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, (array) $this->cacheTags);
         }
     }
 }
 /**
  * Clear event - clear all cache by tags
  * 
  * @param Zend_EventManager_EventDescription $event
  */
 public function clean(\Zend_EventManager_EventDescription $event)
 {
     $params = $event->getParams();
     $mode = \Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG;
     if (isset($params['mode'])) {
         $mode = $params['mode'];
     }
     return $this->cache->clean($mode, $this->_getTags($event));
 }
Example #13
0
 /**
  * Clear search cache
  */
 public function clearConfigCache()
 {
     $capabilities = $this->cache->getBackend()->getCapabilities();
     if (!empty($capabilities['tags'])) {
         $this->cache->clean(\Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, array('Shopware_Config', 'Shopware_Plugin'));
     } else {
         $this->cache->clean();
     }
 }
 /**
  * Overrule this function if you want to perform a different
  * action than deleting when the user choose 'yes'.
  */
 protected function performAction()
 {
     $model = $this->getModel();
     $model->save($this->saveData + $model->getFilter());
     if ($this->cacheTags && $this->cache instanceof \Zend_Cache_Core) {
         $this->cache->clean(\Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, (array) $this->cacheTags);
     }
     $this->setAfterDeleteRoute();
 }
 /**
  * Hook that allows actions when data was saved
  *
  * When not rerouted, the form will be populated afterwards
  *
  * @param int $changed The number of changed rows (0 or 1 usually, but can be more)
  */
 protected function afterSave($changed)
 {
     if ($this->trackEngine) {
         $this->addMessage($this->_('Track merge finished'));
     } else {
         $this->addMessage($this->_('Track import finished'));
     }
     $this->cache->clean(\Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, array('tracks'));
 }
Example #16
0
 /**
  * flushes all cache contents
  *
  * @param array $tags
  * @return boolean
  */
 public function flush(array $tags = array())
 {
     if (null !== $this->cacheAdapter) {
         $prefixedKeys = array();
         foreach ($tags as $key) {
             $prefixedKeys[] = $this->prefixKey($key);
         }
         return $this->cacheAdapter->clean('all', $prefixedKeys);
     }
     return false;
 }
Example #17
0
 /**
  * Clears all set cache data
  *
  * @param string $tag Tag to clear when the default tag name is not used
  * @return void
  */
 public static function clearCache($tag = null)
 {
     if (self::$_cacheTags) {
         if ($tag == null) {
             $tag = 'Zend_Translate';
         }
         self::$_cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array($tag));
     } else {
         self::$_cache->clean(Zend_Cache::CLEANING_MODE_ALL);
     }
 }
Example #18
0
 /**
  * Clears all set cache data
  *
  * @param string $tag Tag to clear when the default tag name is not used
  * @return void
  */
 public static function clearCache($tag = null)
 {
     require_once PHP_LIBRARY_PATH . 'Zend/Cache.php';
     if (self::$_cacheTags) {
         if ($tag == null) {
             $tag = 'Zend_Translate';
         }
         self::$_cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array($tag));
     } else {
         self::$_cache->clean(Zend_Cache::CLEANING_MODE_ALL);
     }
 }
 /**
  * Find a procedure code for the name and organization.
  *
  * @param string $name The name to match against
  * @param int $organizationId Organization id
  * @param boolean $create Create a match when it does not exist
  * @return int or null
  */
 public function matchProcedure($name, $organizationId, $create = true)
 {
     $cacheId = __CLASS__ . '_' . __FUNCTION__;
     $matches = $this->cache->load($cacheId);
     if (!$matches) {
         $matches = array();
         $select = $this->db->select();
         $select->from('gems__agenda_procedures', array('gapr_id_procedure', 'gapr_match_to', 'gapr_id_organization', 'gapr_filter'));
         $result = $this->db->fetchAll($select);
         foreach ($result as $row) {
             if (null === $row['gapr_id_organization']) {
                 $key = 'null';
             } else {
                 $key = $row['gapr_id_organization'];
             }
             foreach (explode('|', $row['gapr_match_to']) as $match) {
                 $matches[$match][$key] = $row['gapr_filter'] ? false : $row['gapr_id_procedure'];
             }
         }
         $this->cache->save($matches, $cacheId, array('procedures'));
     }
     if (isset($matches[$name])) {
         if (isset($matches[$name][$organizationId])) {
             return $matches[$name][$organizationId];
         }
         if (isset($matches[$name]['null'])) {
             return $matches[$name]['null'];
         }
     }
     if (!$create) {
         return null;
     }
     $model = new \MUtil_Model_TableModel('gems__agenda_procedures');
     \Gems_Model::setChangeFieldsByPrefix($model, 'gapr');
     $values = array('gapr_name' => $name, 'gapr_id_organization' => $organizationId, 'gapr_match_to' => $name, 'gapr_active' => 1, 'gapr_filter' => 0);
     $result = $model->save($values);
     $this->cache->clean(\Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, array('procedure', 'procedures'));
     return $result['gapr_id_procedure'];
 }
 /**
  * Clean cache entries
  *
  * Available modes are :
  * 'all' (default)  => remove all cache entries ($tags is not used)
  * 'old'            => remove too old cache entries ($tags is not used)
  * 'matchingTag'    => remove cache entries matching all given tags
  *                     ($tags can be an array of strings or a single string)
  * 'notMatchingTag' => remove cache entries not matching one of the given tags
  *                     ($tags can be an array of strings or a single string)
  * 'matchingAnyTag' => remove cache entries matching any given tags
  *                     ($tags can be an array of strings or a single string)
  *
  * @param  string       $mode
  * @param  array|string $tags
  * @throws Zend_Cache_Exception
  * @return boolean True if ok
  */
 public function clean($mode = 'all', $tags = array())
 {
     $tags = $this->_tags($tags);
     return parent::clean($mode, $tags);
 }
 /**
  * Cleaning cache
  *
  * @param   array $tags
  * @return  Mage_Core_Model_App
  */
 public function cleanCache($tags = array())
 {
     $this->_cache->clean($tags);
     Mage::dispatchEvent('application_clean_cache', array('tags' => $tags));
     return $this;
 }
Example #22
0
 /**
  * Reset cached DDL data from cache
  * if table name is null - reset all cached DDL data
  *
  * @param string $tableName
  * @param string $schemaName OPTIONAL
  * @return Varien_Db_Adapter_Pdo_Mysql
  */
 public function resetDdlCache($tableName = null, $schemaName = null)
 {
     if (!$this->_isDdlCacheAllowed) {
         return $this;
     }
     if ($tableName === null) {
         $this->_ddlCache = array();
         if ($this->_cacheAdapter instanceof Zend_Cache_Core) {
             $this->_cacheAdapter->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array(self::DDL_CACHE_TAG));
         }
     } else {
         $cacheKey = $this->_getTableName($tableName, $schemaName);
         $ddlTypes = array(self::DDL_DESCRIBE, self::DDL_CREATE, self::DDL_INDEX, self::DDL_FOREIGN_KEY);
         foreach ($ddlTypes as $ddlType) {
             unset($this->_ddlCache[$ddlType][$cacheKey]);
         }
         if ($this->_cacheAdapter instanceof Zend_Cache_Core) {
             foreach ($ddlTypes as $ddlType) {
                 $cacheId = $this->_getCacheId($cacheKey, $ddlType);
                 $this->_cacheAdapter->remove($cacheId);
             }
         }
     }
     return $this;
 }
Example #23
0
 /**
  * Deletes all cache entries.
  *
  * @return boolean TRUE if the cache entry was successfully deleted, FALSE otherwise.
  */
 protected function doFlush()
 {
     $this->cache->clean(\Zend_Cache::CLEANING_MODE_MATCHING_TAG, array('Shopware_Models'));
 }
Example #24
0
 /**
  * Delete cache
  */
 public function removeAll()
 {
     $this->zendCache->clean(\Zend_Cache::CLEANING_MODE_ALL);
 }
Example #25
0
 /**
  * Cleans the cache based on the passed parameters.
  *
  * @param string $type Any of
  *       Zend_Cache::CLEANING_MODE_ALL
  *       Zend_Cache::CLEANING_MODE_OLD
  *       Zend_Cache::CLEANING_MODE_MATCHING_TAG
  *       Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG
  *       Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG
  * @param array $options When using any tag related clean up, this array
  * should hold all related tags for this operation
  *
  *
  * @see Zend_Cache::clean
  */
 public function clean($type, array $options = array())
 {
     if (!$this->_cache) {
         return;
     }
     $this->_cache->clean($type, $options);
 }
Example #26
0
 /**
  * Clean cached data by specific tag
  *
  * @return  bool
  */
 public function flush()
 {
     $res = $this->_frontend->clean();
     return $res;
 }
Example #27
0
 /**
  * Clears all set cache data
  *
  * @return void
  */
 public static function clearCache()
 {
     self::$_cache->clean();
 }
 public function clearAllAction()
 {
     $this->_cache->clean(Zend_Cache::CLEANING_MODE_ALL);
     $this->_redirector->gotoSimpleAndExit('index');
 }
Example #29
0
 /**
  * Clears all set cache data
  *
  * @return void
  */
 public static function clearCache()
 {
     require_once 'Zend/Cache.php';
     self::$_cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array('Zend_Translate'));
 }
 public function clean()
 {
     if ($this->_cache) {
         $this->_cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array($this->_id));
     }
 }