code: func (cl *CacheLoader) Load(cache *Cache) error {
  
  	var r *WALSegmentReader
  	for _, fn := range cl.files {
  		if err := func() error {
  			f, err := os.OpenFile(fn, os.O_CREATE|os.O_RDWR, 0666)
  			if err != nil {
  				return err
  			}
  			defer f.Close()
  
  			// Log some information about the segments.
  			stat, err := os.Stat(f.Name())
  			if err != nil {
  				return err
  			}
  			cl.Logger.Info("Reading file", zap.String("path", f.Name()), zap.Int64("size", stat.Size()))
  
  			// Nothing to read, skip it
  			if stat.Size() == 0 {
  				return nil
  			}
  
  			if r == nil {
  				r = NewWALSegmentReader(f)
  				defer r.Close()
  			} else {
  				r.Reset(f)
  			}
  
  			for r.Next() {
  				entry, err := r.Read()
  				if err != nil {
  					n := r.Count()
  					cl.Logger.Info("File corrupt", zap.Error(err), zap.String("path", f.Name()), zap.Int64("pos", n))
  					if err := f.Truncate(n); err != nil {
  						return err
  					}
  					break
  				}
  
  				switch t := entry.(type) {
  				case *WriteWALEntry:
  					if err := cache.WriteMulti(t.Values); err != nil {
  						return err
  					}
  				case *DeleteRangeWALEntry:
  					cache.DeleteRange(t.Keys, t.Min, t.Max)
  				case *DeleteWALEntry:
  					cache.Delete(t.Keys)
  				}
  			}
  
  			return r.Close()
  		}(); err != nil {
  			return err
  		}
  	}
  	return nil
  }
docs: // Load returns a cache loaded with the data contained within the segment files.
  // If, during reading of a segment file, corruption is encountered, that segment
  // file is truncated up to and including the last valid byte, and processing
  // continues with the next segment file.