If the client crashes between the two commands, the lock has no expiry and stays forever
If the client crashes between the two commands, the lock has no expiry and stays forever. The two commands are not atomic. A crash or network failure after SETNX leaves a lock with no TTL. It blocks everyone until someone deletes it by hand. SET key token NX PX 30000 does both in one atomic command.
Read more