Purge all caches

@param   limit purge to subsection
@return  bool
763593
public function delete_all($section)
	{
		// determine the section index name
		$section = $this->config['cache_id'].(empty($section)?'':'.'.$section);

		// get the directory index
		$index = apc_fetch($this->config['cache_id'].'__DIR__');

		if (is_array($index))
		{
			// limit the delete if we have a valid section
			if ( ! empty($section))
			{
				$dirs = in_array($section, $index) ? array($section) : array();
			}
			else
			{
				$dirs = $index;
			}

			// loop through the indexes, delete all stored keys, then delete the indexes
			foreach ($dirs as $dir)
			{
				$list = apc_fetch($dir);
				foreach ($list as $item)
				{
					apc_delete($item[0]);
				}
				apc_delete($dir);
			}

			// update the directory index
			$index = array_diff($index, $dirs);
			apc_store($this->config['cache_id'].'__DIR__', $index);
		}
	}
631416
final public function limit($limit,$offset=null) {
      if (is_numeric($limit) || is_array($limit)) {
         if(is_array($limit)) {
            $temp   = $limit;
            $limit  =  $temp[0];
            $offset = @$temp[1];
         }

         $this->limit = " LIMIT {$limit} ";

         if(is_numeric($offset)) {
            $this->offset( $offset );
         }
         $this->find_first_data = $this->find_save_data = $this->find_delete_data = FALSE;

         $this->get_instance();
         return $this;
      }

      return null;
   }
66583
public function purge() {
        $this->get_store()->purge();
        if ($this->get_loader()) {
            $this->get_loader()->purge();
        }
        return true;
    }
177565
private function purgeRecurse($dir)
    {
        $base = $dir . '/';
        $time = time();
        if (substr($dir, 0, strlen($this->dir)) !== $this->dir) {
            // uh oh, we somehow tried to escape from the cache directory
            assert(0);
            return;
        }
        foreach (scandir($dir) as $f) {
            $fn = $base . $f;

            if ($f[0] === '.') {
                continue;
            }

            if (is_dir($fn)) {
                $this->purgeRecurse($fn);
            } else {
                $update = filemtime($fn);
                if ($time - $update > $this->timeout) {
                    unlink($fn);
                }
            }
        }
    }
625021
public function purge($key)
    {
        $cacheFile = $this->getCachePath($key);

        clearstatcache(true, $cacheFile);
        if (file_exists($cacheFile)) {
            unset($cacheFile);

            return true;
        }

        return false;
    }
672303
def _purge(self):
        
        if len(self.cache) <= self.max_size:
            return

        cache = self.cache
        refcount = self.refcount
        queue = self.queue
        max_size = self.max_size

        # purge least recently used entries, using refcount to count entries
        # that appear multiple times in the queue
        while len(cache) > max_size:
            refc = 1
            while refc:
                k = queue.popleft()
                refc = refcount[k] = refcount[k] - 1
            del cache[k]
            del refcount[k]
58541
public function clear()
    {
        $directory = new \RecursiveIteratorIterator(
            new \RecursiveDirectoryIterator($this->path),
            \RecursiveIteratorIterator::SELF_FIRST
        );

        $cacheIterator = new \RegexIterator($directory, '/^.+\.cache/i', \RecursiveRegexIterator::GET_MATCH);

        $isCleared = false;

        foreach ($cacheIterator as $cacheFiles) {
            foreach ($cacheFiles as $cacheFile) {
                if (false === ($isCleared = unlink($cacheFile))) {
                    return $isCleared;
                    break;
                }
            }
        }

        return $isCleared;
    }
1312370
public function delete_all($section)
	{
		// get the cache root path and prep the requested section
		$path = rtrim(static::$path, '\\/').DS;
		$section = $section === null ? '' : static::identifier_to_path($section).DS;

		// if the path does not exist, bail out immediately
		if ( ! is_dir($path.$section))
		{
			return true;
		}

		// get all files in this section
		$files = \File::read_dir($path.$section, -1, array('\.cache$' => 'file'));

		// closure to recusively delete the files
		$delete = function($folder, $files) use(&$delete, $path)
		{
			$folder = rtrim($folder, '\\/').DS;

			foreach ($files as $dir => $file)
			{
				if (is_numeric($dir))
				{
					if ( ! $result = \File::delete($folder.$file))
					{
						return $result;
					}
				}
				else
				{
					if ( ! $result = ($delete($folder.$dir, $file)))
					{
						return $result;
					}
				}
			}

			// if we're processing a sub directory
			if ($folder != $path)
			{
				// remove the folder if no more files are left
				$files = \File::read_dir($folder);
				empty ($files) and rmdir($folder);
			}

			return true;
		};

		return $delete($path.$section, $files);
	}
881919
public function purge() {
        // 1. Purge the static acceleration array.
        $this->static_acceleration_purge();
        // 2. Purge the store.
        $this->store->purge();
        // 3. Optionally pruge any stacked loaders.
        if ($this->loader) {
            $this->loader->purge();
        }
        return true;
    }
1007616
public function purgeByTag($tags)
    {
        if (is_string($tags)) {
            $tags = [$tags];
        }

        // initialize log
        $log = new DebugLog();
        $log->addMessage('State', 'Purge by cache tag');

        // get caches from index storage
        $cacheKeys = $this->indexStorage->selectByTags($tags);
        if (!is_array($cacheKeys)) {
            return false;
        }

        foreach ($cacheKeys as $ck) {
            // purge from cache storage
            $this->cacheStorage->purge($ck);
        }

        // purge the index storage
        $this->indexStorage->deleteEntryByTags($tags);

        return true;
    }
933166
private function limitOffset($limit, $offset)
    {
        if (!$this->withoutTotalResultCount && !$this->count()) {
            return false;
        }

        $this->queryBuilder
            ->setFirstResult($offset)
            ->setMaxResults($limit);

        return true;
    }
185783
public function delete_all($section)
	{
		// determine the section index name
		$section = empty($section) ? '' : '.'.$section;

		// get the directory index
		$index = static::$redis->get($this->config['cache_id'].':dir:');
		is_null($index) or $index = $this->_unserialize($index);

		if (is_array($index))
		{
			if (!empty($section))
			{
				// limit the delete if we have a valid section
				$dirs = array();
				foreach ($index as $entry)
				{
					if ($entry == $section or strpos($entry, $section.'.') === 0)
					{
						$dirs[] = $entry;
					}
				}
			}
			else
			{
				// else delete the entire contents of the cache
				$dirs = $index;
			}

			// loop through the selected indexes
			foreach ($dirs as $dir)
			{
				// get the stored cache entries for this index
				$list = static::$redis->get($this->config['cache_id'].':index:'.$dir);
				if (is_null($list))
				{
					$list = array();
				}
				else
				{
					$list = $this->_unserialize($list);
				}

				// delete all stored keys
				foreach($list as $item)
				{
					static::$redis->del($item[0]);
				}

				// and delete the index itself
				static::$redis->del($this->config['cache_id'].':index:'.$dir);
			}

			// update the directory index
			static::$redis->set($this->config['cache_id'].':dir:', $this->_serialize(array_diff($index, $dirs)));
		}
	}
942987
public function purgeCacheResult()
    {
        // get cache key
        $cacheKey = $this->getCacheKey();

        // cache the result
        try {
            $cache = $this->cache($this->requestBag->getApiConfig()->get('Cache'));

            return $cache->delete($cacheKey);
        } catch (\Exception $e) {
            throw new RestException('Unable to purge the result from cache. ' . $e->getMessage());
        }
    }
765097
public function clear()
    {
        try {
            $this->_repository
                    ->createQueryBuilder('c')
                    ->delete()
                    ->where('1 = 1')
                    ->getQuery()
                    ->execute();
            $this->resetCacheEntity();
        } catch (\Exception $e) {
            $this->log('warning', sprintf('Enable to clear cache : %s', $e->getMessage()));

            return false;
        }

        return true;
    }
753094
public function removeAll()
    {
        if (!$this->isEmpty()) {
            foreach ($this->getAll() as $key => $val) {
                $this->remove($key);
            }

            return true;
        } else {
            return false;
        }
    }
807982
public function purge() {
        // delete trash and spam
        if ($this->folder==$this->getTrash() || strtolower($this->folder)=="spam") {
            if (imap_delete($this->imap,'1:*') === false) {
                return false;
            }
            return imap_expunge($this->imap);

            // move others to trash
        } else {
            if (imap_mail_move($this->imap,'1:*', $this->getTrash()) == false) {
                return false;
            }
            return imap_expunge($this->imap);
        }
    }
1241148
public function purge()
    {
        if (file_exists($this->directory)) {
            $files          = $this->getCachedFiles();
            $successDeleted = true;
            foreach ($files as $file) {
                $successDeleted &= $this->removeCacheFile($file);
            }

            return (bool)$successDeleted;
        }

        return false;
    }