code: func (db *DB) Save(wr io.Writer) error {
  	var err error
  	db.mu.RLock()
  	defer db.mu.RUnlock()
  	// use a buffered writer and flush every 4MB
  	var buf []byte
  	// iterated through every item in the database and write to the buffer
  	db.keys.Ascend(func(item btree.Item) bool {
  		dbi := item.(*dbItem)
  		buf = dbi.writeSetTo(buf)
  		if len(buf) > 1024*1024*4 {
  			// flush when buffer is over 4MB
  			_, err = wr.Write(buf)
  			if err != nil {
  				return false
  			}
  			buf = buf[:0]
  		}
  		return true
  	})
  	if err != nil {
  		return err
  	}
  	// one final flush
  	if len(buf) > 0 {
  		_, err = wr.Write(buf)
  		if err != nil {
  			return err
  		}
  	}
  	return nil
  }
docs: // Save writes a snapshot of the database to a writer. This operation blocks all
  // writes, but not reads. This can be used for snapshots and backups for pure
  // in-memory databases using the ":memory:". Database that persist to disk
  // can be snapshotted by simply copying the database file.