I know that a single operation of redis is atomic, and multiple operations on redis in the code will not guarantee the atomicity of the entire operation flow.
for example, in the following code, assuming that the value of nums key is 50 and 1000 visits are made to it using the ab.exe tool, the concurrency number is 100. In theory, the result should be negative.
but I have tested nums with a value of 1 many times. Is it because I am testing in the wrong way or is there something wrong with it?
$nums = $redis->get("nums");
if($nums > 1)
$redis->decr("nums");