docs: def _insert_data(self, name, value, timestamp, interval, config, **kwargs):
      '''Helper to insert data into mongo.'''
      # Mongo does not allow mixing atomic modifiers and non-$set sets in the
      # same update, so the choice is to either run the first upsert on
      # {'_id':id} to ensure the record is in place followed by an atomic update
      # based on the series type, or use $set for all of the keys to be used in
      # creating the record, which then disallows setting our own _id because
      # that "can't be updated". So the tradeoffs are:
      #   * 2 updates for every insert, maybe a local cache of known _ids and the
      #     associated memory overhead
      #   * Query by the 2 or 3 key tuple for this interval and the associated
      #     overhead of that index match vs. the presumably-faster match on _id
      #   * Yet another index for the would-be _id of i_key or r_key, where each
      #     index has a notable impact on write performance.
      # For now, choosing to go with matching on the tuple until performance
      # testing can be done. Even then, there may be a variety of factors which
      # make the results situation-dependent.
      insert = {'name':name, 'interval':config['i_calc'].to_bucket(timestamp)}
      if not config['coarse']:
        insert['resolution'] = config['r_calc'].to_bucket(timestamp)
      # copy the query before expire_from as that is not indexed
      query = insert.copy()
  
      if config['expire']:
        insert['expire_from'] = datetime.utcfromtimestamp( timestamp )
  
      # switch to atomic updates
      insert = {'$set':insert.copy()}
  
      # need to hide the period of any values. best option seems to be to pick
      # a character that "no one" uses.
      if isinstance(value, (str,unicode)):
        value = value.replace('.', self._escape_character)
      elif isinstance(value, float):
        value = str(value).replace('.', self._escape_character)
  
      self._insert_type( insert, value )
  
      # TODO: use write preference settings if we have them
      if not kwargs.get('dry_run',False):
        self._client[interval].update( query, insert, upsert=True, check_keys=False )
      return query, insert