Unexpected Output When Accessing Redis Data in Laravel Job's failed Method

30 views Asked by At

I'm working on a Laravel application that uses Redis for data storage and caching. In one of my jobs, I have a failed method that gets called when the job times out or fails. Within this failed method, I'm trying to access some data stored in Redis, both as a hash and a list, but I'm getting unexpected output.

Here's the relevant code from the failed method:

public function failed($exception = null): void
{
    // ...

    if (Redis::exists($this->redisFileKey)) {
        $fileCount = Redis::llen($this->redisFileKey);
        Log::info("File count: " . $fileCount);
    }

    $orderDetails = Redis::hgetall($this->redisMainDataKey);
    Log::info("Order details: " . var_export($orderDetails, true));

    // ...
}

However, the output I'm getting in my logs is unexpected. For ref:

[2024-03-22 19:44:13] local.INFO: File count: timestamp
[2024-03-22 19:44:13] local.ERROR: array_values(): Argument #1 ($array) must be of type array, string given {"exception":"[object] (TypeError(code: 0): array_values(): Argument #1 ($array) must be of type array, string given at /var/www/html/vendor/predis/predis/src/Command/Redis/HGETALL.php:35)

I've double-checked the Redis data using a tool like Redis Insight, and the keys seem to be associated with the correct data types (a list and a hash, respectively).

PS: If the data is not enough, please let me know, I will share some more.

0

There are 0 answers