The pit of incr command and expire command

The Redis Incr command increments the numeric value stored in the key by one. If the key does not exist, the value of the key will be initialized to 0 first, and then the INCR operation will be executed, and the valid time of the key will be set to be valid for a long time.

for example:

$result = $redis->incr($key);
//???
if ($redis->exists($key)) {
    $redis->expire($key, $setTmout);
}

If it happens to be at the question mark, the key just expires

Guess you like

Origin blog.csdn.net/weixin_38230961/article/details/85474353