UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'qZ+iMxsFCAZbyYGhCNjxAyIZALuau8KRxX921yHH88k='
WHERE
key_id = '316234b81a81a09d0bb84ae61e608e0ff6231731937f709b9e98a98387e0ff38'
AND (
token = 'qZ+iMxsFCAZbyYGhCNjxAyIZALuau8KRxX921yHH88k='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)