I am trying to store the last run time of a scheduled job in Laravel. However, the cache is not updating the date. I want the cache to be remembered until the function is called again.
public function setLastRun() {
Cache::forget('last_automation_api_run');
Cache::rememberForever('last_automation_api_run', function () {
return now()->toDateTimeString();
});
}
You should use remember and forget method in different functions.
Every time you delete the cache before fetching cache values makes, logically incorrect.
And you have to
returnthe values coming fromrememberForevercache method.