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!
The following is the syntax to clear cache in Laravel is given below: php artisan cache: clear. php artisan config: clear.
The cache configuration is located at config/cache. php . In this file you may specify which cache driver you would like used by default throughout your application. Laravel supports popular caching backends like Memcached and Redis out of the box.
$ php artisan cache:clear Application cache cleared! This will clear all the cache data in storage which are typically stored in /storage/framework/cache/data/ . The effect is similar to calling the Cache::flush(); Facade method via code.
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
has the function flush
, so you can use:
Cache::flush();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With