UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'uuEY55YHnkzN3BmV+CV/R4yBDxWYWz+qsgEZXtP28CY=' 
WHERE 
  key_id = 'afee3b454874f680f07386885775bf05be50fda4f16a57764a3e0c6cce24858d' 
  AND (
    token = 'uuEY55YHnkzN3BmV+CV/R4yBDxWYWz+qsgEZXtP28CY=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00038