UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'J8cV6QNcnvulnIwsOWBrjliQrJrVIC+8YnJc26FzWEg=' 
WHERE 
  key_id = '9fb9167622760c7b71bf94a98f6dd3359b5256db8619d56ec29d339d20776090' 
  AND (
    token = 'J8cV6QNcnvulnIwsOWBrjliQrJrVIC+8YnJc26FzWEg=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00023