UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'Q0kqNU3PSpgy2ZBs0Tjh+Nbwe4i4VBUeSigD46WrYZM=' 
WHERE 
  key_id = '77da06a55ff2a1215791d75250928eb46c44aeb395cfa75236b700086f296122' 
  AND (
    token = 'Q0kqNU3PSpgy2ZBs0Tjh+Nbwe4i4VBUeSigD46WrYZM=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00022