UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'w9Ak3kWZfSHokRv8qWJKo2bWLlUZrAQCoCZQZzHd4Do='
WHERE
key_id = 'a844e6250c26499bcc322c245d53517b0c99aa720b7cf578656a14c45de499a4'
AND (
token = 'w9Ak3kWZfSHokRv8qWJKo2bWLlUZrAQCoCZQZzHd4Do='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)