UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'H8eBCRCalZGrw1zPXB+3PWbI+lauKXD2pTCSAyA44Y8='
WHERE
key_id = 'bd5fa94578a47203a0f58ecfe7e3ce68171151e206c5d590b369aba35c98f84a'
AND (
token = 'H8eBCRCalZGrw1zPXB+3PWbI+lauKXD2pTCSAyA44Y8='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)