1

I am running Artisan::call('cache:clear'); to clear the cache when the job start.

I am getting following error sometimes and sometimes it works:

Failed to clear cache. Make sure you have the appropriate permissions.

  • does this answer your question, [Failed to clear cache. Make sure you have the appropriate permissions.](https://stackoverflow.com/questions/52231248/laravel-showing-failed-to-clear-cache-make-sure-you-have-the-appropriate-permi) – bhucho Nov 21 '20 at 20:48
  • Ahla w sahla! If you post the code you're trying to run in the queue someone can probably advise an alternative way of doing this. – Citizen Nov 22 '20 at 02:55
  • mar7ba :D I'll put tomorrow the code that run in my job – Noureddine Rmila Nov 22 '20 at 08:45

1 Answers1

0

It's possible you have more than one request running at the exact same time and the files it's trying to access are inaccessible. Rather than running a console command, why not clear the cache of the specific thing you need to be cleared? It's definitely against the spirit of Laravel's caching system to be clearing it every time you're running an item in the queue.

Citizen
  • 12,430
  • 26
  • 76
  • 117
  • We have a dashboard containing result of earnings we have cron that run at midday that clear the cache to update the results in the charts without clearing the cash it show a cached values – Noureddine Rmila Nov 22 '20 at 08:43