arielcr
arielcr

Reputation: 1663

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!

Upvotes: 59

Views: 90472

Answers (3)

The Alpha
The Alpha

Reputation: 146269

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();

Upvotes: 96

afroald
afroald

Reputation: 81

Illuminate\Cache\FileStore has the function flush, so you can use:

Cache::flush();

Upvotes: 7

Anshad Vattapoyil
Anshad Vattapoyil

Reputation: 23483

Use,

use Doctrine\Common\Cache\CacheProvider as DoctrineCache;

DoctrineCache::flushAll();

to flush all cache.

Upvotes: 1

Related Questions