code: func (l *Ledis) Dump(w io.Writer) error {
  	var err error
  
  	var commitID uint64
  	var snap *store.Snapshot
  
  	l.wLock.Lock()
  
  	if l.r != nil {
  		if commitID, err = l.r.LastCommitID(); err != nil {
  			l.wLock.Unlock()
  			return err
  		}
  	}
  
  	if snap, err = l.ldb.NewSnapshot(); err != nil {
  		l.wLock.Unlock()
  		return err
  	}
  	defer snap.Close()
  
  	l.wLock.Unlock()
  
  	wb := bufio.NewWriterSize(w, 4096)
  
  	h := &DumpHead{commitID}
  
  	if err = h.Write(wb); err != nil {
  		return err
  	}
  
  	it := snap.NewIterator()
  	defer it.Close()
  	it.SeekToFirst()
  
  	compressBuf := make([]byte, 4096)
  
  	var key []byte
  	var value []byte
  	for ; it.Valid(); it.Next() {
  		key = it.RawKey()
  		value = it.RawValue()
  
  		if key, err = snappy.Encode(compressBuf, key); err != nil {
  			return err
  		}
  
  		if err = binary.Write(wb, binary.BigEndian, uint16(len(key))); err != nil {
  			return err
  		}
  
  		if _, err = wb.Write(key); err != nil {
  			return err
  		}
  
  		if value, err = snappy.Encode(compressBuf, value); err != nil {
  			return err
  		}
  
  		if err = binary.Write(wb, binary.BigEndian, uint32(len(value))); err != nil {
  			return err
  		}
  
  		if _, err = wb.Write(value); err != nil {
  			return err
  		}
  	}
  
  	if err = wb.Flush(); err != nil {
  		return err
  	}
  
  	compressBuf = nil
  
  	return nil
  }
docs: // Dump dumps data to the Writer.