UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'd5QwXLfz96k/SFCa5F1eNLUxCcr9ilMEVQZT5fTQxEc=' 
WHERE 
  key_id = '50ec3c752802666fcb490af3bca40912390b64237a094ae02c5c7b804ca68af4' 
  AND (
    token = 'd5QwXLfz96k/SFCa5F1eNLUxCcr9ilMEVQZT5fTQxEc=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00040