Flush all cache in Laravel 4

PhpLaravel

Php Problem Overview


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!

Php Solutions


Solution 1 - Php

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

Solution 2 - Php

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

Cache::flush();

Solution 3 - Php

Use,

use Doctrine\Common\Cache\CacheProvider as DoctrineCache;

DoctrineCache::flushAll();

to flush all cache.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionarielcrView Question on Stackoverflow
Solution 1 - PhpThe AlphaView Answer on Stackoverflow
Solution 2 - PhpafroaldView Answer on Stackoverflow
Solution 3 - PhpAnshad VattapoyilView Answer on Stackoverflow