简体   繁体   中英

Flush all cache in Laravel 4

Is there a way to flush all cache in Laravel 4? I'm using file for caching. I read on the docs that you can use Cache::forget('key') , but what if I need to delete all the cache?

An artisan command can also be useful, I think there's an issue on the repo, but not sure if it's implemented yet.

Thanks!

If you run php artisan list then you can find all the commands available for artisan , anyways, there is a command to clear the cache and it's

php artisan cache:clear

Also, you can use

foreach (Cache::getMemory() as $cacheKey => $cacheValue)
{

    Cache::forget($cacheKey);
}

Update:

Cache::flush();

Illuminate\\Cache\\FileStore具有flush功能,因此您可以使用:

Cache::flush();

Use,

use Doctrine\Common\Cache\CacheProvider as DoctrineCache;

DoctrineCache::flushAll();

to flush all cache.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM