Laravel Cache in Process

Viewed 22

I have a problem with caching in queue. I want to cache a simple api response so I did this:

Controller:

CachingProcess::dispatch()->onQueue('system');

        return Cache::rememberForever('cache_data', function() {
            $query = SomeModel::get();

            return new SomeCollection($query);
        });

So the process looks like:

public function handle()
    {
        Cache::rememberForever('cache_data', function() {
            $query= SomeModel::get();

            return new SomeCollection($query);
        });
    }

And in failed_jobs is always returning an error

Exception: Serialization of 'Closure' is not allowed in C:\Users/myuser\Projects\vendor\laravel\framework\src\Illuminate\Cache\FileStore.php:77

Any ideas how to fix that?

0 Answers
Related