Redis has the INCR command that does this in redis without the additional round-trips (and race conditions). It also sets the value to 0 if the key doesn't exist.
So, I actually consider this to be exactly the bad behavior that people accuse Copilot of.