Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flush all cache in Laravel 4

Tags:

php

laravel

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!

like image 723
arielcr Avatar asked Sep 19 '13 17:09

arielcr


People also ask

Which command is used to flush the application cache in Laravel?

The following is the syntax to clear cache in Laravel is given below: php artisan cache: clear. php artisan config: clear.

Where is Laravel config cache?

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.

What does php artisan cache clear do?

$ 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.


2 Answers

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(); 
like image 87
The Alpha Avatar answered Oct 22 '22 16:10

The Alpha


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

Cache::flush(); 
like image 20
afroald Avatar answered Oct 22 '22 15:10

afroald