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.
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.
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.