code: func (db *DB) insertIntoDatabase(item *dbItem) *dbItem {
  	var pdbi *dbItem
  	prev := db.keys.ReplaceOrInsert(item)
  	if prev != nil {
  		// A previous item was removed from the keys tree. Let's
  		// fully delete this item from all indexes.
  		pdbi = prev.(*dbItem)
  		if pdbi.opts != nil && pdbi.opts.ex {
  			// Remove it from the exipres tree.
  			db.exps.Delete(pdbi)
  		}
  		for _, idx := range db.idxs {
  			if idx.btr != nil {
  				// Remove it from the btree index.
  				idx.btr.Delete(pdbi)
  			}
  			if idx.rtr != nil {
  				// Remove it from the rtree index.
  				idx.rtr.Remove(pdbi)
  			}
  		}
  	}
  	if item.opts != nil && item.opts.ex {
  		// The new item has eviction options. Add it to the
  		// expires tree
  		db.exps.ReplaceOrInsert(item)
  	}
  	for _, idx := range db.idxs {
  		if !idx.match(item.key) {
  			continue
  		}
  		if idx.btr != nil {
  			// Add new item to btree index.
  			idx.btr.ReplaceOrInsert(item)
  		}
  		if idx.rtr != nil {
  			// Add new item to rtree index.
  			idx.rtr.Insert(item)
  		}
  	}
  	// we must return the previous item to the caller.
  	return pdbi
  }
docs: // insertIntoDatabase performs inserts an item in to the database and updates
  // all indexes. If a previous item with the same key already exists, that item
  // will be replaced with the new one, and return the previous item.