public function clean()
 {
     eaccelerator_clean();
     eaccelerator_clear();
     eaccelerator_gc();
     eaccelerator_purge();
     return;
 }
Exemple #2
0
 public function delete($id, $tag = FALSE)
 {
     if ($id === TRUE) {
         return eaccelerator_clean();
     }
     if ($tag == FALSE) {
         return eaccelerator_rm($id);
     }
     return TRUE;
 }
 public function delete($id, $tag = FALSE)
 {
     if ($tag === TRUE) {
         Kohana::log('error', 'tags are unsupported by the eAccelerator driver');
         return FALSE;
     } elseif ($id === TRUE) {
         return eaccelerator_clean();
     } else {
         return eaccelerator_rm($id);
     }
 }
Exemple #4
0
 /**
  * 
  * Removes all cache entries.
  * 
  * @return void
  * 
  */
 public function deleteAll()
 {
     if (!$this->_active) {
         return;
     }
     eaccelerator_clean();
 }
 /**
  * Delete all cache entries
  *
  * @return  boolean
  */
 public function delete_all()
 {
     return eaccelerator_clean();
 }
 /**
  * Clears the cache.
  *
  * @return boolean true if ok, false otherwise
  */
 public static function clear()
 {
     switch (self::cacher()) {
         case 'apc':
             return apc_clear_cache('user');
         case 'xcache':
             for ($i = 0, $max = xcache_count(XC_TYPE_VAR); $i < $max; $i++) {
                 if (!xcache_clear_cache(XC_TYPE_VAR, $i)) {
                     return false;
                 }
             }
             return true;
         case 'eaccelerator':
             eaccelerator_clean();
     }
     return false;
 }
Exemple #7
0
/**
 * Empty out the cache in use as best it can
 *
 * It may only remove the files of a certain type (if the $type parameter is given)
 * Type can be user, data or left blank
 *  - user clears out user data
 *  - data clears out system / opcode data
 *  - If no type is specified will perfom a complete cache clearing
 * For cache engines that do not distinguish on types, a full cache flush will be done
 *
 * @param string $type = ''
 */
function clean_cache($type = '')
{
    global $cache_accelerator, $cache_uid, $cache_password, $cache_memcached, $memcached;
    switch ($cache_accelerator) {
        case 'memcached':
            if ((function_exists('memcache_flush') || function_exists('memcached_flush')) && !empty($cache_memcached)) {
                // Not connected yet?
                if (empty($memcached)) {
                    get_memcached_server();
                }
                if (!$memcached) {
                    return;
                }
                // Clear it out, really invalidate whats there
                if (function_exists('memcache_flush')) {
                    memcache_flush($memcached);
                } else {
                    memcached_flush($memcached);
                }
            }
            break;
        case 'eaccelerator':
            if (function_exists('eaccelerator_clear') && function_exists('eaccelerator_clean')) {
                // Clean out the already expired items
                @eaccelerator_clean();
                // Remove all unused scripts and data from shared memory and disk cache,
                // e.g. all data that isn't used in the current requests.
                @eaccelerator_clear();
            }
        case 'mmcache':
            if (function_exists('mmcache_gc')) {
                // Removes all expired keys from shared memory, this is not a complete cache flush :(
                // @todo there is no clear function, should we try to find all of the keys and delete those? with mmcache_rm
                mmcache_gc();
            }
            break;
        case 'apc':
        case 'apcu':
            if (function_exists('apc_clear_cache')) {
                // If passed a type, clear that type out
                if ($type === '' || $type === 'data') {
                    apc_clear_cache('user');
                    apc_clear_cache('system');
                } elseif ($type === 'user') {
                    apc_clear_cache('user');
                }
            }
            break;
        case 'zend':
            if (function_exists('zend_shm_cache_clear')) {
                zend_shm_cache_clear('ELK');
            }
            break;
        case 'xcache':
            if (function_exists('xcache_clear_cache') && function_exists('xcache_count')) {
                // Xcache may need auth credentials, depending on how its been set up
                if (!empty($cache_uid) && !empty($cache_password)) {
                    $_SERVER['PHP_AUTH_USER'] = $cache_uid;
                    $_SERVER['PHP_AUTH_PW'] = $cache_password;
                }
                // Get the counts so we clear each instance
                $pcnt = xcache_count(XC_TYPE_PHP);
                $vcnt = xcache_count(XC_TYPE_VAR);
                // Time to clear the user vars and/or the opcache
                if ($type === '' || $type === 'user') {
                    for ($i = 0; $i < $vcnt; $i++) {
                        xcache_clear_cache(XC_TYPE_VAR, $i);
                    }
                }
                if ($type === '' || $type === 'data') {
                    for ($i = 0; $i < $pcnt; $i++) {
                        xcache_clear_cache(XC_TYPE_PHP, $i);
                    }
                }
            }
            break;
    }
    // To be complete, we also clear out the cache dir so we get any js/css hive files
    if (is_dir(CACHEDIR)) {
        // Remove the cache files in our disk cache directory
        $dh = opendir(CACHEDIR);
        while ($file = readdir($dh)) {
            if ($file != '.' && $file != '..' && $file != 'index.php' && $file != '.htaccess' && (!$type || substr($file, 0, strlen($type)) == $type)) {
                @unlink(CACHEDIR . '/' . $file);
            }
        }
        closedir($dh);
    }
    // Invalidate cache, to be sure!
    // ... as long as Load.php can be modified, anyway.
    @touch(SOURCEDIR . '/Load.php');
    // Give addons a way to trigger cache cleaning.
    call_integration_hook('integrate_clean_cache');
    clearstatcache();
}
Exemple #8
0
    } else {
        eaccelerator_caching(true);
    }
} else {
    if (isset($_POST['optimizer']) && function_exists('eaccelerator_optimizer')) {
        if ($info['optimizer']) {
            eaccelerator_optimizer(false);
        } else {
            eaccelerator_optimizer(true);
        }
    } else {
        if (isset($_POST['clear'])) {
            eaccelerator_clear();
        } else {
            if (isset($_POST['clean'])) {
                eaccelerator_clean();
            } else {
                if (isset($_POST['purge'])) {
                    eaccelerator_purge();
                }
            }
        }
    }
}
$info = eaccelerator_info();
/* }}} */
/* {{{ create_script_table */
function create_script_table($list)
{
    ?>
    <table class="scripts">
 /**
  * Flush cache
  *
  * @return bool
  */
 public function flush()
 {
     @eaccelerator_clean();
     @eaccelerator_clear();
     return true;
 }
Exemple #10
0
 /**
  * Clean some cache records
  *
  * Available modes are :
  * 'all' (default)  => remove all cache entries ($tags is not used)
  * 'old'            => unsupported
  * 'matchingTag'    => unsupported
  * 'notMatchingTag' => unsupported
  * 'matchingAnyTag' => unsupported
  *
  * @param string $mode clean mode
  * @param string[] $tags array of tags
  * @throws \Zend_Cache_Exception
  * @return bool|void true if no problem
  */
 public function clean($mode = \Zend_Cache::CLEANING_MODE_ALL, $tags = array())
 {
     switch ($mode) {
         case \Zend_Cache::CLEANING_MODE_ALL:
             return eaccelerator_clean();
             break;
         case \Zend_Cache::CLEANING_MODE_OLD:
             $this->_log("Magento\\Framework\\Cache\\Backend\\Eaccelerator::clean() : CLEANING_MODE_OLD is unsupported by the Eaccelerator backend");
             break;
         case \Zend_Cache::CLEANING_MODE_MATCHING_TAG:
         case \Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG:
         case \Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG:
             $this->_log(self::TAGS_UNSUPPORTED_BY_CLEAN_OF_EACCELERATOR_BACKEND);
             break;
         default:
             \Zend_Cache::throwException('Invalid mode for clean() method');
             break;
     }
 }
 /**
  * clear cache
  */
 public function clear()
 {
     return eaccelerator_clean();
 }
Exemple #12
0
 /**
  * Clear cache folder
  */
 public function clear()
 {
     eaccelerator_clean();
 }
 /**
  * 缓存清空
  * @return
  */
 public function flushAll()
 {
     @eaccelerator_clean();
     @eaccelerator_clear();
     return;
 }
 public function flush()
 {
     return eaccelerator_clean();
 }
 /**
  * Clean some cache records
  *
  * 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)
  *
  * @param string $mode clean mode
  * @param array $tags array of tags
  * @return boolean true if no problem
  */
 public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
 {
     if ($mode == Zend_Cache::CLEANING_MODE_ALL) {
         return eaccelerator_clean();
     }
     if ($mode == Zend_Cache::CLEANING_MODE_OLD) {
         $this->_log("Zend_Cache_Backend_Eaccelerator::clean() : CLEANING_MODE_OLD is unsupported by the Eaccelerator backend");
     }
     if ($mode == Zend_Cache::CLEANING_MODE_MATCHING_TAG) {
         $idList = array();
         foreach ($tags as $tag) {
             $tagId = $this->_prepareTagId($tag);
             $current_idList = eaccelerator_get($this->_prepareId($tagId));
             if (is_array($current_idList)) {
                 $idList = array_merge($idList, $current_idList);
             }
         }
         //clean up all tags completely
         //remove tagIds from the master tag list
         foreach ($tags as $tag) {
             $tagId = $this->_prepareTagId($tag);
             eaccelerator_rm($this->_prepareId($tagId));
             $this->removeTagUsage($tag);
         }
         //leave if there were no found IDs
         if (count($idList) < 1) {
             return true;
         }
         //remove the deleted IDs from any other tag references
         $masterTagWrapper = eaccelerator_get($this->_getTagStorageId());
         $masterTagList = null;
         if (is_array($masterTagWrapper)) {
             $masterTagList = $masterTagWrapper[0];
         }
         foreach ($masterTagList as $tag) {
             $needsUpdate = false;
             $tagId = $this->_prepareTagId($tag);
             $other_tagList = eaccelerator_get($this->_prepareId($tagId));
             if (is_array($other_tagList)) {
                 foreach ($other_tagList as $_tagIdx => $otherRefId) {
                     if (in_array($otherRefId, $idList)) {
                         unset($other_tagList[$_tagIdx]);
                         $needsUpdate = true;
                     }
                 }
                 if ($needsUpdate) {
                     //completely remove tags if there are no more items in their array.
                     if (count($other_tagList) < 1) {
                         eaccelerator_rm($this->_prepareId($tagId));
                     } else {
                         eaccelerator_put($this->_prepareId($tagId), $other_tagList);
                     }
                 }
             }
         }
         foreach ($idList as $id) {
             eaccelerator_rm($id);
         }
         return true;
     }
     if ($mode == Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG) {
         $this->_log("Zend_Cache_Backend_Eaccelerator::clean() : tags are unsupported by the Eaccelerator backend");
     }
     return $this;
 }