UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'XkuJz3ld63qQwjYCgi3kN67NQ6DqRK6xw+dBdlLqtis='
WHERE
key_id = 'ba079f0982d94494c5eb0d204f9d4b881a953fe0b7401f359a113925c6319a2a'
AND (
token = 'XkuJz3ld63qQwjYCgi3kN67NQ6DqRK6xw+dBdlLqtis='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)