0

I am in need of some help. I want to use Laravel Cache class:

class Uploadcatalogfiles_Task
{
    public function run($arguments)
    {
        error_reporting(0);
        $uploadFlag = Cache::get('upload_is_working');
        if ($uploadFlag == 1) {
            echo date('Y-m-d H:i:s '),'BIT: CACHE SHOT!.',"\n";
            die;
        } else {
            Cache::put('upload_is_working',1,60);
        }

And $uploadFlag is always empty. Seems like Cache is always empty.

What am I doing wrong?

Thanks.

1 Answers1

0

This sounds similar (tho not a duplicate) to this question.

Assuming your cron job is running an artisan command, you likely have an issue where you haven't defined which environment to use when using Laravel's worker.

The docs say to use:

php artisan command:your_command

But you likely want to define a specific environment, like any artisan command, to pull in the right database and cache connections:

php artisan command:your_command --env=production

So, your cron job might look something like this:

* * * * * /usr/bin/php /var/www/example.com/public/artisan command:your_command
Community
  • 1
  • 1
fideloper
  • 12,213
  • 1
  • 41
  • 38
  • I am using `code`* * * * * php /var/www/example.com/public/artisan uploadcatalogfiles --env=local `code` and it works, but cache is empty... – Voron Dmitry Sep 26 '13 at 12:22