OiO.lk Blog PHP Laravel can't get redis key value on For loop
PHP

Laravel can't get redis key value on For loop


I had a problem with Laravel when get a Redis value on loop

public function testLoop()
{
    for($i = 0; $i < 3; $i++) {

        Redis::set('key_'.$i, 'value_'.$i);
        Log::info(Redis::get('key_'.$i));
    }
   
    return true;
}

Laravel successfully set the key but any error on get key

here is the logs, only get the first key

[2024-10-21 09:05:13] local.INFO: value_0
[2024-10-21 09:05:13] local.ERROR: Error while reading line from the server. [tcp://docker.for.mac.localhost:6379] {"userId":569,"exception":"[object] (Predis\Connection\ConnectionException(code: 0): Error while reading line from the server. [tcp://docker.for.mac.localhost:6379] at /var/www/html/vendor/predis/predis/src/Connection/AbstractConnection.php:144)
[stacktrace]

and here the redis key

I’m was try predis or phpredis but same situation

redis timeout has been set to 0

127.0.0.1:6379> config get timeout
1) "timeout"
2) "0"

read_write_timeout on config/database.php has been set to 0

'read_write_timeout' => 0,

i stuck with this situation,, anyone can help ??

thank you


value from redis-cli

redis-cli monitor (stuck at key_1)



You need to sign in to view this answers

Exit mobile version