Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

FrancescoDiMuro's avatar

[Closed] Redis facade seems to be unavailable in a job's failed() method

Good day y'all. I was trying to handle exceptions generated inside the job's handle method, and since I want to save the exception information in the cache (I'm using Redis with PHPRedis), I tried to use the Redis facade in the job's failed() method, but it seems that the Redis commands are not executed inside that method, even though I am able to dd the Redis connection, which reports the correct server's configuration.

So, something like this:

public function failed(Throwable $e): void {
    Redis::set('cacheKey', 'testValue');
}

is not working, as well as getting values from Redis.

EDIT: I tried even with Cache facade, but nothing seems to work. I am executing the queue with the command

php artisan queue:work

What am I missing?

Is it a context problem?

Sorry for the silly questions, but I'm learning Laravel.

Thank you in advance.

Kind regards.

0 likes
5 replies
exSnake's avatar

Did you tried to dd in the failed method? Is it reached?

FrancescoDiMuro's avatar

@exSnake Thanks for the reply! Yes, the failed method is reached (I checked with XDebug), but not Redis nor Cache facades seems to hae any effect in the method.

This is what I see from the dd of the Redis connection:

Unfortunately I don't know how to upload images on here, but the Redis::get that I execute in the failed() method contains just "Redis", but if I try to expand the object properties, nothing is displayed.

FrancescoDiMuro's avatar

I did some more tests, and I've actually found out that the Redis connection between the handle() method and the failed() method. So, basically, it seems that the Redis connection in the failed() method is unable to perform any action because, even if it's apparently available, it seems to be a pending connection. Forcing the disconnection of the Redis client with Redis::disconnect() and using again Redis::connection(), all the methods (->get(), ->set(), and so on) work as expected.

Could it be a bug from Laravel?

Is it the normal behaviour?

Thank you.

FrancescoDiMuro's avatar
FrancescoDiMuro
OP
Best Answer
Level 1

I don't know if this forum has ever been active, but the support I received as a newcomer is equal to zero.

Please or to participate in this conversation.