Prado\I18N\core\TCache_Lite::clean PHP Метод

clean() публичный Метод

if no group is specified all cache files will be destroyed else only cache files of the specified group will be destroyed
public clean ( string $group = false ) : boolean
$group string name of the cache group
Результат boolean true if no problem
    function clean($group = false)
    {
        if ($this->_fileNameProtection) {
            $motif = $group ? 'cache_' . md5($group) . '_' : 'cache_';
        } else {
            $motif = $group ? 'cache_' . $group . '_' : 'cache_';
        }
        if ($this->_memoryCaching) {
            while (list($key, $value) = each($this->_memoryCaching)) {
                if (strpos($key, $motif, 0)) {
                    unset($this->_memoryCaching[$key]);
                    $this->_memoryCachingCounter = $this->_memoryCachingCounter - 1;
                }
            }
            if ($this->_onlyMemoryCaching) {
                return true;
            }
        }
        if (!($dh = opendir($this->_cacheDir))) {
            $this->raiseError('TCache_Lite : Unable to open cache directory !');
            return false;
        }
        while ($file = readdir($dh)) {
            if ($file != '.' && $file != '..') {
                $file = $this->_cacheDir . $file;
                if (is_file($file)) {
                    if (strpos($file, $motif, 0)) {
                        if (!@unlink($file)) {
                            $this->raiseError('Cache_Lite : Unable to remove cache !', -3);
                            return false;
                        }
                    }
                }
            }
        }
        return true;
    }

Usage Example

Пример #1
0
 /**
  * Flush the cache. Deletes all the cache files.
  */
 public function clear()
 {
     $this->cache->clean();
 }