Redis locking problem

while (! $lock) {

        $lock = Redis::set("lock".$id, $random, "nx", "ex" , $ttl);
    }

I want to throw an exception at the timeout I specified in this sentence.

Sep.22,2021

add a line in front of your line of code to determine whether key has expired ~

if ($redis->exists('lock' . $id)) {
    // 
} else {
    // 
}

the above guess about your needs.

Menu