Remove cache files

@param int $expire The number of seconds before expiry
427901
public function cleanup($expire) {
        if ($dir = opendir($this->dir)) {
            while (false !== ($file = readdir($dir))) {
                if(!is_dir($file) && $file != '.' && $file != '..') {
                    $lasttime = @filemtime($this->dir.$file);
                    if (time() - $lasttime > $expire) {
                        @unlink($this->dir.$file);
                    }
                }
            }
            closedir($dir);
        }
    }
1292060
public static function cache($expire = 3600, $last_modify = null) {
        $time    = time();
        $date    = gmdate('D, d M Y H:i:s', $time) . ' GMT';
        $headers = [
            'Age'           => $expire,
            'Date'          => $date,
            'Expires'       => gmdate('D, d M Y H:i:s', $time + $expire) . ' GMT',
            'Cache-Control' => 'public, must-revalidate, max-age=' . $expire,
            'Pragma'        => 'cache'
        ];
        if ($last_modify) {
            $ldate                    = @gmdate('D, d M Y H:i:s', $last_modify) . ' GMT';
            $headers['Last-Modified'] = $ldate;
        }
        foreach ($headers as $header => $val) {
            @header($header . ': ' . $val);
        }
    }
659574
private function removeFromCache($original)
    {
        $cacheKey = $this->getCacheKey($original);
        $cacheContent = $this->cache->fetch($this->getCacheKey($original));
        if (is_array($cacheContent) && isset($cacheContent[$original])) {
            unset($cacheContent[$original]);
            $this->cache->save($cacheKey, $cacheContent);
        }
    }
847090
protected function isExpired( $uri, $expires )
	{
		$edge	= time() - $expires;
		clearstatcache();
		return filemtime( $uri ) <= $edge;
	}
764944
protected function clearExpired()
    {
        if (empty($this->cache)) {
            $file = $this->directory . 'Cache.dat';

            //~ Retrieve Cache information.
            if (file_exists($file)) {
                $content = file_get_contents($file);
                if (!empty($content)) {
                    $this->cache = unserialize($content);
                } else {
                    $this->cache = array();
                }
            }
        }

        // Clean all caches have expired.
        foreach ($this->cache as $pKey => $time) {
            if ($time < time()) {
                $this->remove($pKey);
            }
        }

        return true;
    }
844456
public function purge() {
        // Get all files from the cache folder
        $contents = glob($this->_storage_path . '*');

        // Remove cache files
        foreach ($contents as $content) {
            if (is_file($content)) {
                unlink($content);
            }
        }
    }
1300883
public function set($key, $value, $expire = 0)
    {
        // 如果expire为0时，设为长期有效。
        if ($expire != 0) {
            $expire = time() + $expire;
        } else {
            $expire = time() * 2;
        }

        $value = '<?php exit;?>' . $expire . serialize($value);

        // 检查目录可写否
        $cachedir = APP_PATH . '/' . Config::get("cache_dir");
        if (!is_writeable($cachedir)) {
            \show_error('ERROR: ' . $cachedir . ' is not writeable!');
        }

        return file_put_contents($this->_filename($key), $value);
    }
605354
public function cleanExpiredTokens($expiryTime)
    {
        foreach (glob($this->path.DIRECTORY_SEPARATOR."*".$this->suffix) as $file) {
            if (filemtime($file) < $expiryTime) {
                unlink($file);
            }
        }
    }
328757
public function set(int $value, int $expire = 0): bool
    {
        return parent::setString(strval($value), $expire);
    }
766301
public function setExpire($expire)
	{
		if (null !== $expire)
		{
			$this->expire = $expire instanceof \DateTime ? $expire->getTimestamp() : (int) $expire;
		}
		else
		{
			$this->expire = $expire;
		}

		return $this;
	}
773900
function () {
            var cache = this._cache;
            var expirationTime = ((new Date()).getTime() - this._expiresAfter * 1000);

            for (var url in cache) {
                if (cache.hasOwnProperty(url) && cache[url].age < expirationTime) {
                    delete cache[url];
                }
            }
        }
202329
public function clearCache($olderThan=-1)
	{
		$cacheDirs = new RecursiveDirectoryIterator($this->getCacheDir());
		$cache = new RecursiveIteratorIterator($cacheDirs);
		$expired = time() - $olderThan;
		$count = 0;
		foreach ($cache as $file) {
			if ($cache->isDot() || $cache->isDir() || substr($file, -5) !== '.html') {
				continue;
			}
			if ($cache->getCTime() < $expired) {
				$count += unlink((string) $file) ? 1 : 0;
			}
		}
		return $count;
	}
200100
public function cleanUp( $expires = 0 )
	{
		$expires	= $expires ? $expires : $this->expires;
		if( !$expires )
			throw new InvalidArgumentException( 'No expire time given or set on construction.' );

		$number	= 0;
		$index	= new DirectoryIterator( $this->path );
		foreach( $index as $entry )
		{
			if( $entry->isDot() || $entry->isDir() )
				continue;
			$pathName	= $entry->getPathname();
			if( substr( $pathName, -7 ) !== ".serial" )
				continue;
			if( $this->isExpired( $pathName, $expires ) )
				$number	+= (int) @unlink( $pathName );
		}
		return $number;
	}
981261
public function setCacheExpiration($expires) {
        if (!is_string($expires)) {
            throw new InvalidArgumentException('Cache expiration must be a string in `strtotime()` format');
        }

        $this->_config['cacheExpires'] = (string) $expires;

        return $this;
    }
851869
public function clearExpired() {

		$files = glob(Path :: get('cache-shared') . '*');
		
		if(true === is_array($files) && count($files) > 0) {

			foreach($files as $file) {
			  	
			  	$file 		= new File($file);
				$expiration = $this -> extractExpiration($file);

				if($expiration -> time <= time()) {
					$file -> delete();
				}
			}
		}
		
		return $this;
	}
1037541
public function set($key, $value, $expire = 0)
    {
        $value = '<?php exit;?>' . time() . "($expire)" . serialize($value);

        if ($this->lock) {//自增自减
            fseek($this->lock, 0);
            $return = fwrite($this->lock, $value);
            flock($this->lock, LOCK_UN);
            fclose($this->lock);
            $this->lock = false;
        } else {
            $fileName = $this->getFileName($key);
            $return = file_put_contents($fileName, $value, LOCK_EX);
        }
        $return && clearstatcache();
        return $return;
    }
332047
public function clean()
    {
        foreach ($this->cache as $key => $value) {
            list($expires, $value) = $value;
            if ($expires && ($expires < microtime(true))) {
                unset($this->cache[$key]);
            }
        }
        return true;
    }